// Read reads bytes into buf.
// The bit-ordering mode does not affect this method.
546112
func (pr *Reader) Read(buf []byte) (cnt int, err error) {
	if pr.numBits > 0 {
		if pr.numBits%8 != 0 {
			return 0, errorf(errors.Invalid, "non-aligned bit buffer")
		}
		for cnt = 0; len(buf) > cnt && pr.numBits > 0; cnt++ {
			if pr.bigEndian {
				buf[cnt] = internal.ReverseLUT[byte(pr.bufBits)]
			} else {
				buf[cnt] = byte(pr.bufBits)
			}
			pr.bufBits >>= 8
			pr.numBits -= 8
		}
		return cnt, nil
	}
	if _, err := pr.Flush(); err != nil {
		return 0, err
	}
	cnt, err = pr.rd.Read(buf)
	pr.Offset += int64(cnt)
	return cnt, err
}
52494
func (s *siphon) Read(p []byte) (int, error) {
	n, err := s.f.Read(p)

	if err == nil {
		return s.buf.Write(p[0:n]) // Write must succeed for Read to succeed
	}

	if err == io.EOF {
		s.d.cacheWithoutLock(s.key, s.buf.Bytes()) // cache may fail
		if closeErr := s.f.Close(); closeErr != nil {
			return n, closeErr // close must succeed for Read to succeed
		}
		return n, err
	}

	return n, err
}
839958
func (r *ByteSliceReader) Read(buf []byte) (int, error) {
	count := copy(buf, *r)
	*r = (*r)[count:]
	if len(*r) == 0 {
		*r = nil
	}
	if count < len(buf) {
		return count, io.EOF
	}
	return count, nil
}
680404
func (rwops *RWops) Read(buf []byte) (n int, err error) {
	return rwops.Read2(buf, 1, uint(len(buf)))
}
1317795
func (f *File) Read(b []byte) (int, error) {
	if f.reader == nil {
		if err := f.download(); err != nil {
			return 0, err
		}
	}

	return f.reader.Read(b)
}
195304
func (buf *Buffer) Read(p []byte) (int, error) {
	if len(buf.buf) == 0 {
		if len(p) == 0 {
			return 0, nil
		}
		return 0, io.EOF
	}

	copyLength := len(p)
	if copyLength > len(buf.buf) {
		copyLength = len(buf.buf)
	}

	copy(p, buf.buf)
	zero(buf.buf, len(p))
	buf.buf = buf.buf[copyLength:]
	return copyLength, nil
}
627688
func (gb *Buffer) Read(p []byte) (int, error) {
	gb.Lock()
	defer gb.Unlock()
	return gb.rw.Read(p)
}
1186852
func (r *Reader) Read(buffer []byte) (n int, err error) {
	if r.reader == nil {
		n = len(buffer)
	} else {
		n, err = r.reader.Read(buffer)
	}

	r.count += int64(n)
	if r.onRead != nil {
		r.onRead(r.count)
	}
	return
}
72891
func (r *reader) Read(b []byte) (int, error) {
	switch r := r.WriterTo.(type) {
	case io.Reader:
		return r.Read(b)
	}

	return r.read(b)
}
196696
func (o *offsetReader) Read(p []byte) (int, error) {
	o.lock.Lock()
	defer o.lock.Unlock()

	if o.closed {
		return 0, io.EOF
	}

	return o.buf.Read(p)
}
1308566
func (f FakeFile) Read(p []byte) (n int, err error) {
	return f.Buffer.Read(p)
}
661460
func (b *Buffer) Read(p []byte) (int, error) {
	version := b.preOp()
	n, err := b.buf.Read(p)
	b.postOp(version)
	return n, err
}
917249
func (f *Conn) Read(b []byte) (n int, err error) {
	total := 0

	if f.bytesLeft <= 0 {
		frameSize, err := f.readSize()
		if err != nil {
			return total, err
		}
		f.bytesLeft = frameSize
	}
	n, err = io.ReadFull(f.Conn, b[:min(f.bytesLeft, len(b))])
	f.bytesLeft -= n
	return
}
343598
func (f *File) Read(p []byte) (n int, err error) {
	return f.Data.Read(p)
}
510701
func (s *Snapshot) Read(p []byte) (n int, err error) {
	if s == nil {
		return 0, io.EOF
	}
	return s.file.Read(p)
}
1084885
func (br *bufReader) Read(p []byte) (n int, err error) {
	if br.err != nil {
		return 0, br.err
	}
	return br.buf.Read(p)
}
678086
func (c *Conn) Read(b []byte) (n int, err error) {
	if len(b) == 0 {
		return 0, nil
	}
	err = tryAgain
	for err == tryAgain {
		n, errcb := c.read(b)
		err = c.handleError(errcb)
		if err == nil {
			go c.flushOutputBuffer()
			return n, nil
		}
		if err == io.ErrUnexpectedEOF {
			err = io.EOF
		}
	}
	return 0, err
}