// Read implementes io.Reader
550085
func (r Reader) Read(data []byte) (n int, err error) {
	if r.reader == nil {
		return os.Stdin.Read(data)
	}
	return r.reader.Read(data)
}
826011
func (file *File) Read(buf []byte) (int, error) {
	n, err := file.ReadAt(buf, int64(file.offset))
	if err == nil {
		file.offset += uint64(n)
	}

	return n, err
}
167007
func (t *timeoutReader) Read(p []byte) (int, error) {
	// FIXME limit the amount of data read in one chunk so as to not exceed the timeout?
	// Do the read in the background
	type result struct {
		n   int
		err error
	}
	done := make(chan result, 1)
	go func() {
		n, err := t.reader.Read(p)
		done <- result{n, err}
	}()
	// Wait for the read or the timeout
	timer := time.NewTimer(t.timeout)
	defer timer.Stop()
	select {
	case r := <-done:
		return r.n, r.err
	case <-timer.C:
		t.cancel()
		return 0, TimeoutError
	}
	panic("unreachable") // for Go 1.0
}
255958
func (c *wsConn) Read(b []byte) (int, error) {
	n, err := c.reader.Read(b)
	if err != nil && err != io.EOF {
		return n, err
	} else if err == io.EOF {
		_, r, err := c.conn.NextReader()
		if err != nil {
			return 0, err
		}
		c.reader = r
	}

	return n, nil
}
353472
func (r *tarReader) Read(p []byte) (n int, err error) {
	return r.reader.Read(p)
}
71110
func (b *ByteBuffer) Read(p []byte) (int, error) {
	b.Lock()
	defer b.Unlock()
	return b.b.Read(p)
}
77061
func (f *woFile) Read(p []byte) (n int, err error) {
	return 0, ErrWriteOnly
}
540645
func (t *PosixParser) Read() ([]byte, error) {
	buf := make([]byte, maxReadBytes)
	n, err := syscall.Read(t.fd, buf)
	if err != nil {
		return []byte{}, err
	}
	return buf[:n], nil
}
1287525
func Read(f *os.File) (string, error) {
	ch := make(chan os.Signal, 1)
	signal.Notify(ch, os.Interrupt)
	defer signal.Stop(ch)

	// Run the actual read in a go-routine so that we can still detect signals
	var result string
	var resultErr error
	doneCh := make(chan struct{})
	go func() {
		defer close(doneCh)
		result, resultErr = read(f)
	}()

	// Wait on either the read to finish or the signal to come through
	select {
	case <-ch:
		return "", ErrInterrupted
	case <-doneCh:
		return removeiTermDelete(result), resultErr
	}
}
501459
func (r *Reader) Read(b []byte) (int, error) {
	// if we have data in the buffer, just
	// return that.
	if r.buffered() != 0 {
		x := copy(b, r.data[r.n:])
		r.n += x
		return x, nil
	}
	var n int
	// we have no buffered data; determine
	// whether or not to buffer or call
	// the underlying reader directly
	if len(b) >= cap(r.data) {
		n, r.state = r.r.Read(b)
	} else {
		r.more()
		n = copy(b, r.data)
		r.n = n
	}
	if n == 0 {
		return 0, r.err()
	}
	return n, nil
}
1224866
func (r *LineReader) Read() ([]byte, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line     []byte
		buffer   bytes.Buffer
	)

	for isPrefix && err == nil {
		line, isPrefix, err = r.reader.ReadLine()
		buffer.Write(line)
	}
	buffer.WriteByte('\n')
	return buffer.Bytes(), err
}
510701
func (s *Snapshot) Read(p []byte) (n int, err error) {
	if s == nil {
		return 0, io.EOF
	}
	return s.file.Read(p)
}
1054816
func (f *FileReadSeeker) Read(p []byte) (int, error) {
	return f.file.Read(p)
}
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)
}
690752
func (f *KbfsReadCloseResetter) Read(p []byte) (int, error) {
	content, err := f.client.SimpleFSRead(f.ctx, keybase1.SimpleFSReadArg{
		OpID:   f.opid,
		Offset: atomic.LoadInt64(&f.offset),
		Size:   len(p),
	})
	if err != nil {
		return 0, err
	}
	if len(content.Data) == 0 {
		// Unfortunately SimpleFSRead doesn't return EOF error.
		return 0, io.EOF
	}
	atomic.AddInt64(&f.offset, int64(len(content.Data)))
	copy(p, content.Data)
	return len(content.Data), nil
}
312692
func (conn *WebsocketConnection) Read(b []byte) (n int, err error) {
	if conn.reader == nil {
		err = conn.waitForReader()
		if err != nil {
			return
		}
	}

	rn, rerr := conn.reader.Read(b)
	switch rerr {
	case io.EOF:
		conn.reader = nil
	default:
		n, err = rn, rerr
	}
	return
}
595313
func (l *Locking) Read(p []byte) (n int, err error) {
	l.Lock()
	n, err = l.R.Read(p)
	l.Unlock()
	return
}