Welcome to mirror list, hosted at ThFree Co, Russian Federation.

StreamWrapper.cs « Compression « Library « Duplicati - github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 66d3cdbd84661388b0b4ab0a91bb980f1f38f48b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.IO;

namespace Duplicati.Library.Compression
{

    /// <summary>
    /// CompressionStream wrapper to prevent closing the base stream when disposing the entry stream
    /// </summary>
    public class StreamWrapper : Utility.OverrideableStream
    {
        public delegate void DisposingHandler(StreamWrapper sender);

        public event DisposingHandler Disposing;

        public StreamWrapper(Stream stream)
            : base(stream)
        {
        }

        protected override void Dispose(bool disposing)
        {
            if (!disposing || m_basestream == null) return;

            if (Disposing != null)
                Disposing(this);

            m_basestream.Dispose();
            m_basestream = null;
        }

        public long GetSize()
        {
            return m_basestream == null ? 0 : m_basestream.Length;
        }
    }
}