Rewind N bytes in Stream.
975147
public void rewindNbytes(int N)
   {
      int bits = (N << 3);
	  totbit -= bits;
	  buf_byte_idx -= bits;	  
	  if (buf_byte_idx<0)
		  buf_byte_idx += BUFSIZE;
   }
1141517
def skipBytes(self, nroBytes):
        
        self.data.seek(nroBytes + self.data.tell())
241582
def Stream(self, reader, amount=None):
    
    if amount is None:
      amount = float("inf")

    data = reader.Read(min(self.chunk_size, amount))
    if not data:
      return

    amount -= len(data)
    offset = reader.offset - len(data)
    yield Chunk(offset=offset, data=data)

    while amount > 0:
      # We need `len(data)` here because overlap size can be 0.
      overlap = data[len(data) - self.overlap_size:]

      new = reader.Read(min(self.chunk_size - self.overlap_size, amount))
      if not new:
        return

      data = overlap + new

      amount -= len(new)
      offset = reader.offset - len(data)
      yield Chunk(offset=offset, data=data, overlap=len(overlap))
899033
@Override
	public long skip(long n) throws IOException {
		if (defaultSkip) {
			// use skip method of parent stream
			// may not work if skip not implemented by parent
			long bs = super.skip(n);
			bytesRead += bs;

			return bs;
		}

		if (n <= 0) {
			return 0;
		}

		long left = n;
		byte[] sBuff = new byte[SKIP_BUFFER_SIZE];

		while (left > 0) {
			int res = read(sBuff, 0, (int) (left < SKIP_BUFFER_SIZE ? left : SKIP_BUFFER_SIZE));
			if (res < 0) {
				break;
			}
			left -= res;
		}

		return n - left;
	}
791920
protected void reBuffer() {
        resetBuffer();

        try {
            if (bufferOffset >= fs.getFileStatus(inputPath).getLen()) // TODO: is this equivalent?
                return;

            input.seek(bufferOffset);

            int read = 0;

            while (read < buffer.length) {
                int n = input.read(buffer, read, buffer.length - read);
                if (n < 0)
                    break;
                read += n;
            }

            validBufferBytes = read;
            bytesSinceCacheFlush += read;
        } catch (IOException e) {
            throw new FSReadError(e, filePath);
        }
    }
548997
def read (self, stream):
      """"""
      self._data = stream.read(self._size)

      if len(self._data) >= self._size:
          values = struct.unpack(self._swap + self._format, self._data)
      else:
          values = None, None, None, None

      self.ts_sec   = values[0]
      self.ts_usec  = values[1]
      self.incl_len = values[2]
      self.orig_len = values[3]
1271594
def read(self, n=-1):
        
        if n < -1:
            raise IOError('Cannot read backwards')

        bytes = self._buffer.read(n)

        return bytes
783813
def _parse(self, stream, context, path):
        """"""
        start = stream.tell()
        read_bytes = ""
        if self.max_length:
            read_bytes = stream.read(self.max_length)
        else:
            read_bytes = stream.read()
        skip = read_bytes.find(self.find) + len(self.find)
        stream.seek(start + skip)
        return skip
252184
def _read_stream_for_size(stream):
    """"""
    size = 0
    while True:
        buf = stream.read(_BUFFER_SIZE)
        size += len(buf)
        if not buf:
            break
    return size
18974
public function rewind()
    {
        if ($this->hasHeadline()) {
            $this->updateHeadline();
            $lineNumber = 1;
        } else {
            $lineNumber = 0;
        }
        $this->initialLineNumber = $lineNumber;
        $this->seekFileToCurrentLineNumberIfNeeded(
            $this->getFileHandler(),
            $lineNumber
        );
    }
80738
def _multiplexed_buffer_helper(self, response):
        """"""
        buf = self._result(response, binary=True)
        buf_length = len(buf)
        walker = 0
        while True:
            if buf_length - walker < STREAM_HEADER_SIZE_BYTES:
                break
            header = buf[walker:walker + STREAM_HEADER_SIZE_BYTES]
            _, length = struct.unpack_from('>BxxxL', header)
            start = walker + STREAM_HEADER_SIZE_BYTES
            end = start + length
            walker = end
            yield buf[start:end]
666809
def peek(self, n=1):
        """"""
        if n > len(self._readbuffer) - self._offset:
            chunk = self.read(n)
            if len(chunk) > self._offset:
                self._readbuffer = chunk + self._readbuffer[self._offset:]
                self._offset = 0
            else:
                self._offset -= len(chunk)

        # Return up to 512 bytes to reduce allocation overhead for tight loops.
        return self._readbuffer[self._offset: self._offset + 512]
637231
def read(self, n):
        
        buf = self._read_buf
        pos = self._read_pos
        end = pos + n

        if end <= len(buf):
            # Fast path: the data to read is fully buffered.
            self._read_pos += n
            return self._update_pos(buf[pos:end])

        # Slow path: read from the stream until enough bytes are read,
        # or until an EOF occurs or until read() would block.
        wanted = max(self.buffer_size, n)
        while len(buf) < end:
            chunk = self.raw.read(wanted)
            if not chunk:
                break
            buf += chunk

        self._read_buf = buf[end:]  # Save the extra data in the buffer.
        self._read_pos = 0
        return self._update_pos(buf[pos:end])
303814
def peek(self, n=1):
        """"""
        if n > len(self._readbuffer) - self._offset:
            chunk = self.read(n)
            self._offset -= len(chunk)

        # Return up to 512 bytes to reduce allocation overhead for tight loops.
        return self._readbuffer[self._offset: self._offset + 512]
208115
protected void reBuffer()
    {
        resetBuffer();

        try
        {
            int read = buffer.length;
            if (bufferOffset + read > fileLength)
            {
                if (bufferOffset >= fileLength)
                    return;
                read = (int) (fileLength - bufferOffset);
            }

            channel.position(bufferOffset); // setting channel position

            int offset = 0;
            while (read > 0)
            {
                int n = super.read(buffer, offset, read);
                if (n < 0)
                    throw new IllegalStateException();
                read -= n;
                offset += n;
            }

            validBufferBytes = offset;
        }
        catch (IOException e)
        {
            throw new FSReadError(e, filePath);
        }
    }
561558
def _feed_buffer(self, n=1):
        
        buffer = bytearray(self._stream.read())
        while len(buffer) < n:
            try:
                message = yield from self._protocol.recv()
            except ConnectionClosed:
                message = None
            if message is None:
                break
            if not isinstance(message, bytes):
                raise TypeError("message must be bytes")
            buffer.extend(message)
        self._stream = io.BytesIO(buffer)
1174837
public long skip(long n) throws IOException {
        long s = super.skip(n);
        if( s<n && filenames.hasNext() ) {
            cueStream();
            return s + skip(n-s);
        }
        return s;
    }