GZipArchiveEntry.cs 901 B

12345678910111213141516171819202122232425262728293031323334
  1. using System.IO;
  2. using System.Linq;
  3. using SharpCompress.Common.GZip;
  4. namespace SharpCompress.Archives.GZip
  5. {
  6. public class GZipArchiveEntry : GZipEntry, IArchiveEntry
  7. {
  8. internal GZipArchiveEntry(GZipArchive archive, GZipFilePart part)
  9. : base(part)
  10. {
  11. Archive = archive;
  12. }
  13. public virtual Stream OpenEntryStream()
  14. {
  15. //this is to reset the stream to be read multiple times
  16. var part = Parts.Single() as GZipFilePart;
  17. if (part.GetRawStream().Position != part.EntryStartPosition)
  18. {
  19. part.GetRawStream().Position = part.EntryStartPosition;
  20. }
  21. return Parts.Single().GetCompressedStream();
  22. }
  23. #region IArchiveEntry Members
  24. public IArchive Archive { get; }
  25. public bool IsComplete => true;
  26. #endregion
  27. }
  28. }