예제 #1
0
        /// <summary>
        /// Disposes of the open stream and the temporary file.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (_locked != null)
            {
                try
                {
                    if (_committed && disposing)
                    {
                        using (Stream source = Read(FileShare.Read))
                        {
                            long length = source.Length;
                            long copied = IOStream.CopyStream(source, _locked);
                            _locked.SetLength(copied);

                            Check.Assert <IOException>(length == copied);
                        }
                    }
                }
                finally
                {
                    _locked.Dispose();
                    _locked = null;

                    if (_created && !_committed && disposing)
                    {
                        try { File.Delete(_targetFile); }
                        catch { }
                    }
                }
            }
            base.Dispose(disposing);
        }
 /// <summary> Decompress the source stream to the specified target stream. </summary>
 public static long Decompress(Stream source, Stream target)
 {
     using (Stream gz = new GZipStream(source, CompressionMode.Decompress, true))
         return(IOStream.CopyStream(gz, target));
 }