internal void WriteInSector(int secID, int position, int[] integers) { int sectorOffset = this.GetSectorOffset(secID); this.FileStorage.Position = (long)checked (sectorOffset + position); CompoundDocument.WriteArrayOfInt32(this.Writer, integers); }
internal int AllocateNewSector(int[] sectorData) { int totalSectors = this.TotalSectors; this.FileStorage.Position = (long)this.GetSectorOffset(totalSectors); CompoundDocument.WriteArrayOfInt32(this.Writer, sectorData); checked { this.TotalSectors++; return(totalSectors); } }
private static void WriteHeader(BinaryWriter writer, FileHeader header) { writer.Write(header.FileTypeIdentifier); writer.Write(header.FileIdentifier.ToByteArray()); writer.Write(header.RevisionNumber); writer.Write(header.VersionNumber); writer.Write(header.ByteOrderMark); writer.Write(header.SectorSizeInPot); writer.Write(header.ShortSectorSizeInPot); writer.Write(header.UnUsed10); writer.Write(header.NumberOfSATSectors); writer.Write(header.FirstSectorIDofDirectoryStream); writer.Write(header.UnUsed4); writer.Write(header.MinimumStreamSize); writer.Write(header.FirstSectorIDofShortSectorAllocationTable); writer.Write(header.NumberOfShortSectors); writer.Write(header.FirstSectorIDofMasterSectorAllocationTable); writer.Write(header.NumberOfMasterSectors); CompoundDocument.WriteArrayOfInt32(writer, header.MasterSectorAllocationTable); }
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 void Save() { checked { if (this.ShortSectorAllocationTable.Count > 0) { if (this.Document.Header.FirstSectorIDofShortSectorAllocationTable == -2) { int num = this.Document.SectorSize / 4; int[] array = new int[num]; for (int i = 0; i < array.Length; i++) { array[i] = -1; } this.Document.Header.FirstSectorIDofShortSectorAllocationTable = this.Document.AllocateDataSector(); this.Document.WriteInSector(this.Document.Header.FirstSectorIDofShortSectorAllocationTable, 0, array); } MemoryStream memoryStream = new MemoryStream(this.ShortSectorAllocationTable.Count * 4); CompoundDocument.WriteArrayOfInt32(new BinaryWriter(memoryStream), this.ShortSectorAllocationTable.ToArray()); this.Document.WriteStreamData(this.Document.Header.FirstSectorIDofShortSectorAllocationTable, memoryStream.ToArray()); } } }