// Read implements the io.ReadCloser interface.
194158
func (fb *fileBuffer) Read(p []byte) (int, error) {
	return fb.b.Read(p)
}
507814
func (r *YAMLReader) Read() ([]byte, error) {
	var buffer bytes.Buffer
	for {
		line, err := r.reader.Read()
		if err != nil && err != io.EOF {
			return nil, err
		}

		sep := len([]byte(separator))
		if i := bytes.Index(line, []byte(separator)); i == 0 {
			// We have a potential document terminator
			i += sep
			after := line[i:]
			if len(strings.TrimRightFunc(string(after), unicode.IsSpace)) == 0 {
				if buffer.Len() != 0 {
					return buffer.Bytes(), nil
				}
				if err == io.EOF {
					return nil, err
				}
			}
		}
		if err == io.EOF {
			if buffer.Len() != 0 {
				// If we're at EOF, we have a final, non-terminated line. Return it.
				return buffer.Bytes(), nil
			}
			return nil, err
		}
		buffer.Write(line)
	}
}
87121
func (r *cachingReadCloser) Read(p []byte) (n int, err error) {
	n, err = r.R.Read(p)
	r.buf.Write(p[:n])
	if err == io.EOF {
		r.OnEOF(bytes.NewReader(r.buf.Bytes()))
	}
	return n, err
}
141577
func (o *MemoryObject) Reader() (io.ReadCloser, error) {
	return ioutil.NopCloser(bytes.NewBuffer(o.cont)), nil
}
107805
func (r *ByteReader) Read(b []byte) (n int, err error) {
	if len(b) == 0 {
		return 0, nil
	}
	if r.off >= len(r.buf) {
		return 0, io.EOF
	}
	n = copy(b, r.buf[r.off:])
	r.off += n
	return
}
554370
func (d *driver) Reader(ctx context.Context, path string, offset int64) (io.ReadCloser, error) {
	d.mutex.RLock()
	defer d.mutex.RUnlock()

	return d.reader(ctx, path, offset)
}
568043
func (d *Decoder) Read() uint64 {
	v := d.buf[d.i]
	return v
}
1050952
func (c *Conn) Read(b []byte) (int, error) {
	if c.R == nil {
		return 0, c.readErr(false, io.EOF)
	}

	c.initClosing()

	// stop now if we're already closed
	select {
	case <-c.closing:
		return 0, c.readErr(false, connClosed)
	default:
	}

	// stop now if we're already timed out
	c.rdeadmu.RLock()
	defer c.rdeadmu.RUnlock()
	if !c.rdead.IsZero() && c.rdead.Before(time.Now()) {
		return 0, c.readErr(true, timedOut)
	}

	// start read
	readc := make(chan nerr, 1)
	go func() {
		c.rmu.Lock()
		n, err := c.R.Read(b)
		c.rmu.Unlock()
		readc <- nerr{n, err}
	}()

	// set up deadline timeout
	var timeout <-chan time.Time
	timer := deadlineTimer(c.rdead) // c.rdeadmu read lock already held above
	if timer != nil {
		timeout = timer.C
		defer timer.Stop()
	}

	// wait for read success, timeout, or closing
	select {
	case <-c.closing:
		return 0, c.readErr(false, connClosed)
	case <-timeout:
		return 0, c.readErr(true, timedOut)
	case nerr := <-readc:
		if nerr.err != nil {
			// wrap the error
			return nerr.n, c.readErr(false, nerr.err)
		}
		return nerr.n, nil
	}
}
571716
func (s *TranslateFile) Reader(ctx context.Context, offset int64) (io.ReadCloser, error) {
	rc := newTranslateFileReader(ctx, s, offset)
	if err := rc.Open(); err != nil {
		return nil, err
	}
	return rc, nil
}
309955
func (g *GetObjectReader) Read(p []byte) (n int, err error) {
	n, err = g.pReader.Read(p)
	if err != nil {
		// Calling code may not Close() in case of error, so
		// we ensure it.
		g.Close()
	}
	return
}
1004068
func (lr LineReader) Read(p []byte) (int, error) {
	return lr.r.Read(p)
}
973331
func (r *readSeekCloserVerifier) Read(p []byte) (n int, err error) {
	n, err = r.rsc.Read(p)
	if r.hash != nil {
		if n > 0 {
			r.hash.Write(p[:n])
		}
		if err == io.EOF {
			actual := digest.NewDigest(r.expect.Algorithm(), r.hash)
			if actual != r.expect {
				return n, fmt.Errorf("content integrity error: the blob streamed from digest %s does not match the digest calculated from the content %s", r.expect, actual)
			}
		}
	}
	return n, err
}
489625
func (f *FileReader) Read(b []byte) (int, error) {
	if f.closed {
		return 0, io.ErrClosedPipe
	}

	if f.info.IsDir() {
		return 0, &os.PathError{
			"read",
			f.name,
			errors.New("is a directory"),
		}
	}

	if f.offset >= f.info.Size() {
		return 0, io.EOF
	}

	if len(b) == 0 {
		return 0, nil
	}

	if f.blocks == nil {
		err := f.getBlocks()
		if err != nil {
			return 0, err
		}
	}

	if f.blockReader == nil {
		err := f.getNewBlockReader()
		if err != nil {
			return 0, err
		}
	}

	for {
		n, err := f.blockReader.Read(b)
		f.offset += int64(n)

		if err != nil && err != io.EOF {
			f.blockReader.Close()
			f.blockReader = nil
			return n, err
		} else if n > 0 {
			return n, nil
		} else {
			f.blockReader.Close()
			f.getNewBlockReader()
		}
	}
}
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
	}
}
1266362
func (s *Scanner) read() {
	if s.eof {
		return
	}

	r, w, err := s.r.ReadRune()
	if err != nil {
		s.fatalError(err)
		return
	}

	s.cur = r
	s.cpos.Off += s.cw
	s.cw = w

	// newline is '\n' as in Go
	if r == '\n' {
		s.cpos.Line++
		s.cpos.Col = 0
	} else {
		s.cpos.Col++
	}
}
500885
func Read(file string) (*Data, error) {
	data := New()
	if err := data.Open(file); err != nil {
		return nil, err
	}
	return data, nil
}
152004
func (c *Conn) Read(p []byte) (int, error) {
	return c.r.Read(p)
}