Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/4.0.3/EPPlus-4.0.3/Packaging/DotNetZip/OffsetStream.cs @ 18172

Last change on this file since 18172 was 12074, checked in by sraggl, 10 years ago

#2341: Added EPPlus-4.0.3 to ExtLibs

File size: 2.9 KB
Line 
1// OffsetStream.cs
2// ------------------------------------------------------------------
3//
4// Copyright (c)  2009 Dino Chiesa
5// All rights reserved.
6//
7// This code module is part of DotNetZip, a zipfile class library.
8//
9// ------------------------------------------------------------------
10//
11// This code is licensed under the Microsoft Public License.
12// See the file License.txt for the license details.
13// More info on: http://dotnetzip.codeplex.com
14//
15// ------------------------------------------------------------------
16//
17// last saved (in emacs):
18// Time-stamp: <2009-August-27 12:50:35>
19//
20// ------------------------------------------------------------------
21//
22// This module defines logic for handling reading of zip archives embedded
23// into larger streams.  The initial position of the stream serves as
24// the base offset for all future Seek() operations.
25//
26// ------------------------------------------------------------------
27
28
29using System;
30using System.IO;
31
32namespace OfficeOpenXml.Packaging.Ionic.Zip
33{
34    internal class OffsetStream : System.IO.Stream, System.IDisposable
35    {
36        private Int64 _originalPosition;
37        private Stream _innerStream;
38
39        public OffsetStream(Stream s)
40            : base()
41        {
42            _originalPosition = s.Position;
43            _innerStream = s;
44        }
45
46        public override int Read(byte[] buffer, int offset, int count)
47        {
48            return _innerStream.Read(buffer, offset, count);
49        }
50
51        public override void Write(byte[] buffer, int offset, int count)
52        {
53            throw new NotImplementedException();
54        }
55
56        public override bool CanRead
57        {
58            get { return _innerStream.CanRead; }
59        }
60
61        public override bool CanSeek
62        {
63            get { return _innerStream.CanSeek; }
64        }
65
66        public override bool CanWrite
67        {
68            get { return false; }
69        }
70
71        public override void Flush()
72        {
73            _innerStream.Flush();
74        }
75
76        public override long Length
77        {
78            get
79            {
80                return _innerStream.Length;
81            }
82        }
83
84        public override long Position
85        {
86            get { return _innerStream.Position - _originalPosition; }
87            set { _innerStream.Position = _originalPosition + value; }
88        }
89
90
91        public override long Seek(long offset, System.IO.SeekOrigin origin)
92        {
93            return _innerStream.Seek(_originalPosition + offset, origin) - _originalPosition;
94        }
95
96
97        public override void SetLength(long value)
98        {
99            throw new NotImplementedException();
100        }
101
102        void IDisposable.Dispose()
103        {
104            Close();
105        }
106
107        public override void Close()
108        {
109            base.Close();
110        }
111
112    }
113
114}
Note: See TracBrowser for help on using the repository browser.