SeekableFilePart.cs 936 B

123456789101112131415161718192021222324252627282930313233
  1. using System.IO;
  2. using SharpCompress.Common.Rar;
  3. using SharpCompress.Common.Rar.Headers;
  4. namespace SharpCompress.Archives.Rar
  5. {
  6. internal class SeekableFilePart : RarFilePart
  7. {
  8. private readonly Stream stream;
  9. private readonly string password;
  10. internal SeekableFilePart(MarkHeader mh, FileHeader fh, Stream stream, string password)
  11. : base(mh, fh)
  12. {
  13. this.stream = stream;
  14. this.password = password;
  15. }
  16. internal override Stream GetCompressedStream()
  17. {
  18. stream.Position = FileHeader.DataStartPosition;
  19. #if !NO_CRYPTO
  20. if (FileHeader.R4Salt != null)
  21. {
  22. return new RarCryptoWrapper(stream, password, FileHeader.R4Salt);
  23. }
  24. #endif
  25. return stream;
  26. }
  27. internal override string FilePartName => "Unknown Stream - File Entry: " + FileHeader.FileName;
  28. }
  29. }