CMSProcessableFile.cs 1.3 KB

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