Volume.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System.IO;
  2. using SharpCompress.IO;
  3. using SharpCompress.Readers;
  4. namespace SharpCompress.Common
  5. {
  6. public abstract class Volume : IVolume
  7. {
  8. private readonly Stream _actualStream;
  9. internal Volume(Stream stream, ReaderOptions readerOptions)
  10. {
  11. ReaderOptions = readerOptions;
  12. if (readerOptions.LeaveStreamOpen)
  13. {
  14. stream = new NonDisposingStream(stream);
  15. }
  16. _actualStream = stream;
  17. }
  18. internal Stream Stream => _actualStream;
  19. protected ReaderOptions ReaderOptions { get; }
  20. /// <summary>
  21. /// RarArchive is the first volume of a multi-part archive.
  22. /// Only Rar 3.0 format and higher
  23. /// </summary>
  24. public virtual bool IsFirstVolume => true;
  25. /// <summary>
  26. /// RarArchive is part of a multi-part archive.
  27. /// </summary>
  28. public virtual bool IsMultiVolume => true;
  29. private bool _disposed;
  30. public void Dispose()
  31. {
  32. if (!_disposed)
  33. {
  34. _actualStream.Dispose();
  35. _disposed = true;
  36. }
  37. }
  38. }
  39. }