CMSProcessableFile.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System.IO;
  4. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  5. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO;
  6. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Cms
  7. {
  8. /**
  9. * a holding class for a file of data to be processed.
  10. */
  11. public class CmsProcessableFile
  12. : CmsProcessable, CmsReadable
  13. {
  14. private const int DefaultBufSize = 32 * 1024;
  15. private readonly FileInfo _file;
  16. private readonly int _bufSize;
  17. public CmsProcessableFile(FileInfo file)
  18. : this(file, DefaultBufSize)
  19. {
  20. }
  21. public CmsProcessableFile(FileInfo file, int bufSize)
  22. {
  23. _file = file;
  24. _bufSize = bufSize;
  25. }
  26. public virtual Stream GetInputStream()
  27. {
  28. return new FileStream(_file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read, _bufSize);
  29. }
  30. public virtual void Write(Stream zOut)
  31. {
  32. using (var inStr = _file.OpenRead())
  33. {
  34. Streams.PipeAll(inStr, zOut, _bufSize);
  35. }
  36. }
  37. }
  38. }
  39. #pragma warning restore
  40. #endif