public MasterSectorAllocation(CompoundDocument document)
 {
     this.Document = document;
     this.NumberOfSecIDs = document.Header.NumberOfSATSectors;
     this.CurrentMSATSector = document.Header.FirstSectorIDofMasterSectorAllocationTable;
     this.SecIDCapacity = document.SectorSize / 4 - 1;
     InitializeMasterSectorAllocationTable();
 }
 public static CompoundDocument Create(Stream stream,BinaryWriter bWriter)
 {
     Writer = bWriter;
     //FileStream stream = File.Open(file, FileMode.Create, FileAccess.ReadWrite, FileShare.Read);
     CompoundDocument document = new CompoundDocument(stream, new CompoundFileHeader());
     document.WriteHeader();
     document.MasterSectorAllocation.AllocateSATSector();
     document.InitializeDirectoryEntries();
     return document;
 }
 public ShortSectorAllocation(CompoundDocument document)
 {
     this.Document = document;
     ShortSectorAllocationTable = document.GetStreamDataAsIntegers(document.Header.FirstSectorIDofShortSectorAllocationTable);
     //ShortSectorAllocationTable.RemoveRange(document.Header.NumberOfShortSectors, ShortSectorAllocationTable.Count - document.Header.NumberOfShortSectors);
     while (ShortSectorAllocationTable.Count > 0 && ShortSectorAllocationTable[ShortSectorAllocationTable.Count - 1] == SID.Free)
     {
         ShortSectorAllocationTable.RemoveAt(ShortSectorAllocationTable.Count - 1);
     }
 }
 public void Save()
 {
     if (ShortSectorAllocationTable.Count > 0)
     {
         if (Document.Header.FirstSectorIDofShortSectorAllocationTable == SID.EOC)
         {
             int   SecIDCapacity = Document.SectorSize / 4;
             int[] sids          = new Int32[SecIDCapacity];
             for (int i = 0; i < sids.Length; i++)
             {
                 sids[i] = SID.Free;
             }
             Document.Header.FirstSectorIDofShortSectorAllocationTable = Document.AllocateDataSector();
             Document.WriteInSector(Document.Header.FirstSectorIDofShortSectorAllocationTable, 0, sids);
         }
         MemoryStream satStream = new MemoryStream(ShortSectorAllocationTable.Count * 4);
         CompoundDocument.WriteArrayOfInt32(new BinaryWriter(satStream), ShortSectorAllocationTable.ToArray());
         Document.WriteStreamData(Document.Header.FirstSectorIDofShortSectorAllocationTable, satStream.ToArray());
     }
 }
        public static CompoundDocument Open(FileStream stream)
        {
            //FileStream stream = File.Open(file, FileMode.Open, FileAccess.ReadWrite, FileShare.Read);
            BinaryReader reader = new BinaryReader(stream);
            FileHeader header = ReadHeader(reader);

            CompoundDocument document = new CompoundDocument(stream, header);
            if (!document.CheckHeader()) return null;

            document.ReadDirectoryEntries();

            return document;
        }
Example #6
0
 public DirectoryEntry(CompoundDocument document, string name)
     : this(name)
 {
     Document = document;
 }
 public SectorAllocation(CompoundDocument document)
 {
     this.Document = document;
     this.SecIDCapacity = document.SectorSize / 4;
 }
 public SectorAllocation(CompoundDocument document)
 {
     this.Document      = document;
     this.SecIDCapacity = document.SectorSize / 4;
 }