/// <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)); }
/** * 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++)); }
/// <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); }
/// <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]); }
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; } }
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; } }
/// <summary><inheritDoc/></summary> /// <exception cref="System.IO.IOException"/> public virtual int Get(long position) { return(source.Get(position)); }