/// <summary> /// Reads from the <see cref="stream" /> /// </summary> /// <param name="stream"></param> public void Read(Stream stream) { var streamRw = new StreamRW(stream); EntryName = streamRw.ReadBytes(64); NameLength = streamRw.ReadUInt16(); StgType = (StgType)streamRw.ReadByte(); streamRw.ReadByte(); LeftSibling = streamRw.ReadInt32(); RightSibling = streamRw.ReadInt32(); Child = streamRw.ReadInt32(); if (StgType == StgType.StgInvalid) { LeftSibling = Nostream; RightSibling = Nostream; Child = Nostream; } StorageCLSID = new Guid(streamRw.ReadBytes(16)); StateBits = streamRw.ReadInt32(); CreationDate = streamRw.ReadBytes(8); ModifyDate = streamRw.ReadBytes(8); StartSector = streamRw.ReadInt32(); Size = streamRw.ReadInt64(); }
/// <summary> /// Writes to the <see cref="stream" /> /// </summary> /// <param name="stream"></param> public void Write(Stream stream) { var streamRw = new StreamRW(stream); streamRw.Write(HeaderSignature); streamRw.Write(CLSID); streamRw.Write(MinorVersion); streamRw.Write(MajorVersion); streamRw.Write(ByteOrder); streamRw.Write(SectorShift); streamRw.Write(MiniSectorShift); streamRw.Write(UnUsed); streamRw.Write(DirectorySectorsNumber); streamRw.Write(FATSectorsNumber); streamRw.Write(FirstDirectorySectorId); streamRw.Write(UnUsed2); streamRw.Write(MinSizeStandardStream); streamRw.Write(FirstMiniFATSectorId); streamRw.Write(MiniFATSectorsNumber); streamRw.Write(FirstDIFATSectorId); streamRw.Write(DIFATSectorsNumber); foreach (var i in DIFAT) { streamRw.Write(i); } if (MajorVersion == 4) { var zeroHead = new byte[3584]; streamRw.Write(zeroHead); } streamRw.Close(); }
/// <summary> /// Reads from the <see cref="stream" /> /// </summary> /// <param name="stream"></param> public void Read(Stream stream) { var streamRw = new StreamRW(stream); HeaderSignature = streamRw.ReadBytes(8); CheckSignature(); CLSID = streamRw.ReadBytes(16); MinorVersion = streamRw.ReadUInt16(); MajorVersion = streamRw.ReadUInt16(); CheckVersion(); ByteOrder = streamRw.ReadUInt16(); SectorShift = streamRw.ReadUInt16(); MiniSectorShift = streamRw.ReadUInt16(); UnUsed = streamRw.ReadBytes(6); DirectorySectorsNumber = streamRw.ReadInt32(); FATSectorsNumber = streamRw.ReadInt32(); FirstDirectorySectorId = streamRw.ReadInt32(); UnUsed2 = streamRw.ReadUInt32(); MinSizeStandardStream = streamRw.ReadUInt32(); FirstMiniFATSectorId = streamRw.ReadInt32(); MiniFATSectorsNumber = streamRw.ReadUInt32(); FirstDIFATSectorId = streamRw.ReadInt32(); DIFATSectorsNumber = streamRw.ReadUInt32(); for (var i = 0; i < 109; i++) { DIFAT[i] = streamRw.ReadInt32(); } streamRw.Close(); }
/// <summary> /// Writes to the <see cref="stream" /> /// </summary> /// <param name="stream"></param> public void Write(Stream stream) { var streamRw = new StreamRW(stream); streamRw.Write(EntryName); streamRw.Write(NameLength); streamRw.Write((byte)StgType); streamRw.Write((byte)StgColor); streamRw.Write(LeftSibling); streamRw.Write(RightSibling); streamRw.Write(Child); streamRw.Write(StorageCLSID.ToByteArray()); streamRw.Write(StateBits); streamRw.Write(CreationDate); streamRw.Write(ModifyDate); streamRw.Write(StartSector); streamRw.Write(Size); streamRw.Close(); }
/// <summary> /// Writes to the <see cref="stream" /> /// </summary> /// <param name="stream"></param> public void Write(Stream stream) { var streamRw = new StreamRW(stream); streamRw.Write(HeaderSignature); streamRw.Write(CLSID); streamRw.Write(MinorVersion); streamRw.Write(MajorVersion); streamRw.Write(ByteOrder); streamRw.Write(SectorShift); streamRw.Write(MiniSectorShift); streamRw.Write(UnUsed); streamRw.Write(DirectorySectorsNumber); streamRw.Write(FATSectorsNumber); streamRw.Write(FirstDirectorySectorId); streamRw.Write(UnUsed2); streamRw.Write(MinSizeStandardStream); streamRw.Write(FirstMiniFATSectorId); streamRw.Write(MiniFATSectorsNumber); streamRw.Write(FirstDIFATSectorId); streamRw.Write(DIFATSectorsNumber); foreach (var i in DIFAT) streamRw.Write(i); if (MajorVersion == 4) { var zeroHead = new byte[3584]; streamRw.Write(zeroHead); } streamRw.Close(); }
/// <summary> /// Reads from the <see cref="stream" /> /// </summary> /// <param name="stream"></param> public void Read(Stream stream) { var streamRw = new StreamRW(stream); HeaderSignature = streamRw.ReadBytes(8); CheckSignature(); CLSID = streamRw.ReadBytes(16); MinorVersion = streamRw.ReadUInt16(); MajorVersion = streamRw.ReadUInt16(); CheckVersion(); ByteOrder = streamRw.ReadUInt16(); SectorShift = streamRw.ReadUInt16(); MiniSectorShift = streamRw.ReadUInt16(); UnUsed = streamRw.ReadBytes(6); DirectorySectorsNumber = streamRw.ReadInt32(); FATSectorsNumber = streamRw.ReadInt32(); FirstDirectorySectorId = streamRw.ReadInt32(); UnUsed2 = streamRw.ReadUInt32(); MinSizeStandardStream = streamRw.ReadUInt32(); FirstMiniFATSectorId = streamRw.ReadInt32(); MiniFATSectorsNumber = streamRw.ReadUInt32(); FirstDIFATSectorId = streamRw.ReadInt32(); DIFATSectorsNumber = streamRw.ReadUInt32(); for (var i = 0; i < 109; i++) DIFAT[i] = streamRw.ReadInt32(); streamRw.Close(); }