ICSharpCode.SharpZipLib.Zip.ZipFile.PartialInputStream.Seek C# (CSharp) Method

Seek() public method

When overridden in a derived class, sets the position within the current stream.
An I/O error occurs. The stream does not support seeking, such as if the stream is constructed from a pipe or console output. Methods were called after the stream was closed.
public Seek ( long offset, SeekOrigin origin ) : long
offset long A byte offset relative to the origin parameter.
origin SeekOrigin A value of type indicating the reference point used to obtain the new position.
return long
            public override long Seek(long offset, SeekOrigin origin) {
                long newPos=readPos_;

                switch (origin) {
                    case SeekOrigin.Begin:
                        newPos=start_+offset;
                        break;

                    case SeekOrigin.Current:
                        newPos=readPos_+offset;
                        break;

                    case SeekOrigin.End:
                        newPos=end_+offset;
                        break;
                }

                if (newPos<start_) {
                    throw new ArgumentException("Negative position is invalid");
                }

                if (newPos>=end_) {
                    throw new IOException("Cannot seek past end");
                }
                readPos_=newPos;
                return readPos_;
            }