private static void WriteBytes(byte[] data, int size, Stream outStream, int sectorSize) { outStream.Write(data, 0, size); int num = CompoundFileData.Padding(size, sectorSize); for (int i = 0; i < num; i++) { outStream.WriteByte(0); } }
private static int CreateChain(int streamSize, ArrayList allocationTable, int sectorSize) { int num = allocationTable.Count; int num2 = CompoundFileData.SectorCount(streamSize, sectorSize); for (int i = 0; i < (num2 - 1); i++) { allocationTable.Add(allocationTable.Count + 1); } allocationTable.Add(-2); return(num); }
private void WriteDirectoryStream(BinaryWriter bw) { foreach (CompoundFileData.RedBlackTreeNode node in this.nodes) { this.WriteDirectoryNode(bw, node); } int streamSize = this.nodes.Count * 128; int num2 = CompoundFileData.Padding(streamSize, base.sectorSize); for (int i = 0; i < num2; i++) { bw.Write(0); } }
private void WriteMATRemainder(BinaryWriter bw) { if (base.SATSectorCount > 0x6d) { for (int i = 0x6d; i < base.SATSectorCount; i++) { bw.Write(base.sectorAllocationTableSID + i); } int streamSize = (base.SATSectorCount - 0x6d) * 4; int num3 = CompoundFileData.Padding(streamSize, base.sectorSize) / 4; for (int j = 0; j < num3; j++) { bw.Write(-1); } } }
private void WriteAllocationTable(BinaryWriter bw, ArrayList allocationTable) { //using ( IEnumerator enumerator = allocationTable.GetEnumerator(); //) { while (enumerator.MoveNext()) { int num = (int)enumerator.Current; // *(enumerator.get_Current()); bw.Write(num); } } int streamSize = allocationTable.Count * 4; int num3 = CompoundFileData.Padding(streamSize, base.sectorSize) / 4; for (int i = 0; i < num3; i++) { bw.Write(-1); } }
private void BuildSATAndMAT() { int sectorSize = base.sectorSize / 4; int num3 = sectorSize - 1; int streamSize = base.sectorAllocationTable.Count; while (true) { int num = streamSize; base.SATSectorCount = CompoundFileData.SectorCount(streamSize, sectorSize); if (base.SATSectorCount <= 0x6d) { base.MATSectorCount = 0; } else { base.MATSectorCount = CompoundFileData.SectorCount(base.SATSectorCount - 0x6d, num3); } streamSize = (base.sectorAllocationTable.Count + base.SATSectorCount) + base.MATSectorCount; if (streamSize <= num) { base.sectorAllocationTableSID = this.FillSAT(base.SATSectorCount, CompoundFileData.SpecialSIDs.SAT); if (base.MATSectorCount > 0) { base.masterAllocationTableSID = this.FillSAT(base.MATSectorCount, CompoundFileData.SpecialSIDs.MSAT); } else { base.masterAllocationTableSID = -2; } if (base.sectorAllocationTable.Count != streamSize) { throw new CompoundFileException("Internal error: wrong SAT / MAT calculation."); } return; } } }