DirectoryEndHeader.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.IO;
  2. namespace SharpCompress.Common.Zip.Headers
  3. {
  4. internal class DirectoryEndHeader : ZipHeader
  5. {
  6. public DirectoryEndHeader()
  7. : base(ZipHeaderType.DirectoryEnd)
  8. {
  9. }
  10. internal override void Read(BinaryReader reader)
  11. {
  12. VolumeNumber = reader.ReadUInt16();
  13. FirstVolumeWithDirectory = reader.ReadUInt16();
  14. TotalNumberOfEntriesInDisk = reader.ReadUInt16();
  15. TotalNumberOfEntries = reader.ReadUInt16();
  16. DirectorySize = reader.ReadUInt32();
  17. DirectoryStartOffsetRelativeToDisk = reader.ReadUInt32();
  18. CommentLength = reader.ReadUInt16();
  19. Comment = reader.ReadBytes(CommentLength);
  20. }
  21. public ushort VolumeNumber { get; private set; }
  22. public ushort FirstVolumeWithDirectory { get; private set; }
  23. public ushort TotalNumberOfEntriesInDisk { get; private set; }
  24. public uint DirectorySize { get; private set; }
  25. public uint DirectoryStartOffsetRelativeToDisk { get; private set; }
  26. public ushort CommentLength { get; private set; }
  27. public byte[] Comment { get; private set; }
  28. public ushort TotalNumberOfEntries { get; private set; }
  29. public bool IsZip64 => TotalNumberOfEntriesInDisk == ushort.MaxValue
  30. || DirectorySize == uint.MaxValue
  31. || DirectoryStartOffsetRelativeToDisk == uint.MaxValue;
  32. }
  33. }