コード例 #1
0
 /// <summary>
 /// <inheritDoc/>
 /// Note that the position will be adjusted to read from the corrected location in the underlying source
 /// </summary>
 /// <exception cref="System.IO.IOException"/>
 public virtual int Get(long position)
 {
     if (position >= length)
     {
         return(-1);
     }
     return(source.Get(offset + position));
 }
コード例 #2
0
        /**
         * Reads a single byte
         * @return the byte, or -1 if EOF is reached
         * @throws IOException
         */

        virtual public int Read()
        {
            if (isBack)
            {
                isBack = false;
                return(back & 0xff);
            }
            return(byteSource.Get(byteSourcePosition++));
        }
コード例 #3
0
        /// <summary><inheritDoc/></summary>
        public override int Read(byte[] b, int off, int len)
        {
            int count = source.Get(position, b, off, len);

            if (count == -1)
            {
                return(0);
            }
            position += count;
            return(count);
        }
コード例 #4
0
        /// <summary><inheritDoc/></summary>
        /// <exception cref="System.IO.IOException"/>
        public virtual int Get(long position)
        {
            if (position < getBufferStart || position > getBufferEnd)
            {
                int count = source.Get(position, getBuffer, 0, getBuffer.Length);
                if (count == -1)
                {
                    return(-1);
                }
                getBufferStart = position;
                getBufferEnd   = position + count - 1;
            }
            int bufPos = (int)(position - getBufferStart);

            return(0xff & getBuffer[bufPos]);
        }
コード例 #5
0
 public static void CopyBytes(IRandomAccessSource source, long start, long length, Stream outs) {
     if (length <= 0)
         return;
     long idx = start;
     byte[] buf = new byte[8192];
     while (length > 0) {
         long n = source.Get(idx, buf,0, (int)Math.Min((long)buf.Length, length));
         if (n <= 0)
             throw new EndOfStreamException();
         outs.Write(buf, 0, (int)n);
         idx += n;
         length -= n;
     }
 }
コード例 #6
0
ファイル: StreamUtil.cs プロジェクト: SonjaKoenig/SopraBackup
        public static void CopyBytes(IRandomAccessSource source, long start, long length, Stream outs)
        {
            if (length <= 0)
            {
                return;
            }
            long idx = start;

            byte[] buf = new byte[8192];
            while (length > 0)
            {
                long n = source.Get(idx, buf, 0, (int)Math.Min((long)buf.Length, length));
                if (n <= 0)
                {
                    throw new EndOfStreamException();
                }
                outs.Write(buf, 0, (int)n);
                idx    += n;
                length -= n;
            }
        }
コード例 #7
0
 /// <summary><inheritDoc/></summary>
 /// <exception cref="System.IO.IOException"/>
 public virtual int Get(long position)
 {
     return(source.Get(position));
 }