// Implies mode = Compress public DeflateStream(Stream stream, CompressionLevel compressionLevel, bool leaveOpen) { if (stream == null) { throw new ArgumentNullException("stream"); } if (!stream.CanWrite) { throw new ArgumentException(SR.NotWriteableStream, "stream"); } // Checking of compressionLevel is passed down to the IDeflater implementation as it // is a pugable component that completely encapsulates the meaning of compressionLevel. Contract.EndContractBlock(); _stream = stream; _mode = CompressionMode.Compress; _leaveOpen = leaveOpen; _deflater = CreateDeflater(compressionLevel); _buffer = new byte[DefaultBufferSize]; }
public DeflateStream(Stream stream, CompressionMode mode, bool leaveOpen) { if (stream == null) throw new ArgumentNullException("stream"); switch (mode) { case CompressionMode.Decompress: if (!stream.CanRead) { throw new ArgumentException(SR.NotReadableStream, "stream"); } _inflater = CreateInflater(); break; case CompressionMode.Compress: if (!stream.CanWrite) { throw new ArgumentException(SR.NotWriteableStream, "stream"); } _deflater = CreateDeflater(null); break; default: throw new ArgumentException(SR.ArgumentOutOfRange_Enum, "mode"); } _stream = stream; _mode = mode; _leaveOpen = leaveOpen; _buffer = new byte[DefaultBufferSize]; }
public DeflateStream(Stream stream, CompressionMode mode, bool leaveOpen) { if (stream == null) { throw new ArgumentNullException("stream"); } switch (mode) { case CompressionMode.Decompress: if (!stream.CanRead) { throw new ArgumentException(SR.NotReadableStream, "stream"); } _inflater = new Inflater(); break; case CompressionMode.Compress: if (!stream.CanWrite) { throw new ArgumentException(SR.NotWriteableStream, "stream"); } _deflater = CreateDeflater(null); break; default: throw new ArgumentException(SR.ArgumentOutOfRange_Enum, "mode"); } _stream = stream; _mode = mode; _leaveOpen = leaveOpen; _buffer = new byte[DefaultBufferSize]; }
protected override void Dispose(bool disposing) { try { PurgeBuffers(disposing); } finally { // Close the underlying stream even if PurgeBuffers threw. // Stream.Close() may throw here (may or may not be due to the same error). // In this case, we still need to clean up internal resources, hence the inner finally blocks. try { if (disposing && !_leaveOpen && _stream != null) { _stream.Dispose(); } } finally { _stream = null; try { if (deflater != null) { deflater.Dispose(); } } finally { deflater = null; base.Dispose(disposing); } } // finally } // finally } // Dispose
// Implies mode = Compress public DeflateStream(Stream stream, CompressionLevel compressionLevel, bool leaveOpen) { if (stream == null) { throw new ArgumentNullException("stream"); } if (!stream.CanWrite) { throw new ArgumentException(SR.GetString(SR.NotWriteableStream), "stream"); } // Checking of compressionLevel is passed down to the IDeflater implementation as it // is a pluggable component that completely encapsulates the meaning of compressionLevel. _stream = stream; _mode = CompressionMode.Compress; _leaveOpen = leaveOpen; deflater = CreateDeflater(compressionLevel); #if !NETFX_CORE m_AsyncWriterDelegate = new AsyncWriteDelegate(this.InternalWrite); m_CallBack = new AsyncCallback(WriteCallback); #endif buffer = new byte[DefaultBufferSize]; }
protected override void Dispose(bool disposing) { try { this.PurgeBuffers(disposing); } finally { try { if (disposing && !this._leaveOpen && this._stream != null) { this._stream.Dispose(); } } finally { this._stream = null; try { if (this.deflater != null) { this.deflater.Dispose(); } } finally { this.deflater = null; base.Dispose(disposing); } } } }
public DeflateStream(Stream stream, CompressionMode mode, bool leaveOpen) { if (stream == null) { throw new ArgumentNullException("stream"); } if (CompressionMode.Compress != mode && CompressionMode.Decompress != mode) { throw new ArgumentException(SR.GetString(SR.ArgumentOutOfRange_Enum), "mode"); } _stream = stream; _mode = mode; _leaveOpen = leaveOpen; switch (_mode) { case CompressionMode.Decompress: if (!_stream.CanRead) { throw new ArgumentException(SR.GetString(SR.NotReadableStream), "stream"); } inflater = new Inflater(); #if !NETFX_CORE m_CallBack = new AsyncCallback(ReadCallback); #endif break; case CompressionMode.Compress: if (!_stream.CanWrite) { throw new ArgumentException(SR.GetString(SR.NotWriteableStream), "stream"); } deflater = CreateDeflater(); #if !NETFX_CORE m_AsyncWriterDelegate = new AsyncWriteDelegate(this.InternalWrite); m_CallBack = new AsyncCallback(WriteCallback); #endif break; } // switch (_mode) buffer = new byte[DefaultBufferSize]; }
public DeflateStream(Stream stream, CompressionMode mode, bool leaveOpen) { if(stream == null ) throw new ArgumentNullException("stream"); if (CompressionMode.Compress != mode && CompressionMode.Decompress != mode) throw new ArgumentException(SR.GetString(SR.ArgumentOutOfRange_Enum), "mode"); _stream = stream; _mode = mode; _leaveOpen = leaveOpen; switch (_mode) { case CompressionMode.Decompress: if (!_stream.CanRead) { throw new ArgumentException(SR.GetString(SR.NotReadableStream), "stream"); } inflater = new Inflater(); #if !NETFX_CORE m_CallBack = new AsyncCallback(ReadCallback); #endif break; case CompressionMode.Compress: if (!_stream.CanWrite) { throw new ArgumentException(SR.GetString(SR.NotWriteableStream), "stream"); } deflater = CreateDeflater(); #if !NETFX_CORE m_AsyncWriterDelegate = new AsyncWriteDelegate(this.InternalWrite); m_CallBack = new AsyncCallback(WriteCallback); #endif break; } // switch (_mode) buffer = new byte[DefaultBufferSize]; }
public DeflateStream(Stream stream, CompressionMode mode, bool leaveOpen) { if (stream == null) { throw new ArgumentNullException("stream"); } if (CompressionMode.Compress != mode && mode != CompressionMode.Decompress) { throw new ArgumentException(SR.GetString("Argument out of range"), "mode"); } this._stream = stream; this._mode = mode; this._leaveOpen = leaveOpen; CompressionMode mode2 = this._mode; if (mode2 != CompressionMode.Decompress) { if (mode2 == CompressionMode.Compress) { if (!this._stream.CanWrite) { throw new ArgumentException(SR.GetString("Not a writeable stream"), "stream"); } this.deflater = DeflateStream.CreateDeflater(); this.m_AsyncWriterDelegate = new DeflateStream.AsyncWriteDelegate(this.InternalWrite); this.m_CallBack = new AsyncCallback(this.WriteCallback); } } else { if (!this._stream.CanRead) { throw new ArgumentException(SR.GetString("Not a readable stream"), "stream"); } this.inflater = new Inflater(); this.m_CallBack = new AsyncCallback(this.ReadCallback); } this.buffer = new byte[8192]; }
public DeflateStream(Stream stream, CompressionMode mode, bool leaveOpen) { if (stream == null) { throw new ArgumentNullException(nameof(stream)); } if (CompressionMode.Compress != mode && (uint)mode > 0U) { throw new ArgumentException(SR.GetString("Argument out of range"), nameof(mode)); } this._stream = stream; this._mode = mode; this._leaveOpen = leaveOpen; switch (this._mode) { case CompressionMode.Decompress: if (!this._stream.CanRead) { throw new ArgumentException(SR.GetString("Not a readable stream"), nameof(stream)); } this.inflater = new Inflater(); this.m_CallBack = new AsyncCallback(this.ReadCallback); break; case CompressionMode.Compress: if (!this._stream.CanWrite) { throw new ArgumentException(SR.GetString("Not a writeable stream"), nameof(stream)); } this.deflater = DeflateStream.CreateDeflater(); this.m_AsyncWriterDelegate = new DeflateStream.AsyncWriteDelegate(this.InternalWrite); this.m_CallBack = new AsyncCallback(this.WriteCallback); break; } this.buffer = new byte[8192]; }
// Implies mode = Compress public DeflateStream(Stream stream, CompressionLevel compressionLevel, bool leaveOpen) { if (stream == null) throw new ArgumentNullException("stream"); if (!stream.CanWrite) throw new ArgumentException(SR.NotWriteableStream, "stream"); // Checking of compressionLevel is passed down to the IDeflater implementation as it // is a pugable component that completely encapsulates the meaning of compressionLevel. Contract.EndContractBlock(); _stream = stream; _mode = CompressionMode.Compress; _leaveOpen = leaveOpen; _deflater = CreateDeflater(compressionLevel); _buffer = new byte[DefaultBufferSize]; }
protected override void Dispose(bool disposing) { try { PurgeBuffers(disposing); } finally { // Close the underlying stream even if PurgeBuffers threw. // Stream.Close() may throw here (may or may not be due to the same error). // In this case, we still need to clean up internal resources, hence the inner finally blocks. try { if (disposing && !_leaveOpen && _stream != null) _stream.Dispose(); } finally { _stream = null; try { if (_deflater != null) _deflater.Dispose(); if (_inflater != null) _inflater.Dispose(); } finally { _deflater = null; _inflater = null; base.Dispose(disposing); } } // finally } // finally } // Dispose
// Implies mode = Compress public DeflateStream(Stream stream, CompressionLevel compressionLevel, bool leaveOpen) { if (stream == null) throw new ArgumentNullException("stream"); if (!stream.CanWrite) throw new ArgumentException(SR.GetString(SR.NotWriteableStream), "stream"); // Checking of compressionLevel is passed down to the IDeflater implementation as it // is a pluggable component that completely encapsulates the meaning of compressionLevel. Contract.EndContractBlock(); _stream = stream; _mode = CompressionMode.Compress; _leaveOpen = leaveOpen; deflater = CreateDeflater(compressionLevel); m_AsyncWriterDelegate = new AsyncWriteDelegate(this.InternalWrite); m_CallBack = new AsyncCallback(WriteCallback); buffer = new byte[DefaultBufferSize]; }
public DeflateDiskSaver( IDeflater deflater, string folder, TimeSpan border, ITelemetryLogger logger ) { if (deflater == null) { throw new ArgumentNullException("deflater"); } if (logger == null) { throw new ArgumentNullException("logger"); } //folder allowed to be null if (border.TotalSeconds >= 0) { throw new ArgumentException("border must be less than zero. Recommended value is -1 month."); } _deflater = deflater; _logger = logger; _folder = string.IsNullOrEmpty(folder) ? "PerfLog" : folder; _border = border; //создаем папку, если не создано CreateIfNotExists(); //удаляем старье DeleteOld(); //читаем актуальные параметры ReadConfig(); //следующая папка при каждом старте сейвера CheckForNextFolder(); }