SingleVolumeRarReader.cs 812 B

123456789101112131415161718192021222324252627282930
  1. using System.IO;
  2. using SharpCompress.Common;
  3. using SharpCompress.Common.Rar;
  4. namespace SharpCompress.Readers.Rar
  5. {
  6. internal class SingleVolumeRarReader : RarReader
  7. {
  8. private readonly Stream stream;
  9. internal SingleVolumeRarReader(Stream stream, ReaderOptions options)
  10. : base(options)
  11. {
  12. this.stream = stream;
  13. }
  14. internal override void ValidateArchive(RarVolume archive)
  15. {
  16. if (archive.IsMultiVolume) {
  17. var msg = "Streamed archive is a Multi-volume archive. Use different RarReader method to extract.";
  18. throw new MultiVolumeExtractionException(msg);
  19. }
  20. }
  21. protected override Stream RequestInitialStream()
  22. {
  23. return stream;
  24. }
  25. }
  26. }