// Seek implements the Seeker interface for syntheticByteStream
768917
func (s *syntheticByteStream) Seek(offset int64, whence int) (int64, error) {
	s.mu.Lock()
	defer s.mu.Unlock()

	switch whence {
	case io.SeekStart:
		s.offset = offset
	case io.SeekCurrent:
		s.offset += offset
	case io.SeekEnd:
		s.offset = s.size - offset
	default:
		return 0, errors.New("Seek: invalid whence")
	}

	if s.offset < 0 {
		return 0, errors.New("Seek: invalid offset")
	}

	return s.offset, nil
}
781518
func (br *Reader) Seek(off bgzf.Offset) error {
	return br.r.Seek(off)
}
529996
func (t *PrimaryTree) SeekLast() (e *PrimaryEnumerator, err error) {
	q := t.last
	if q == nil {
		return nil, io.EOF
	}

	return btEPool1.get(nil, true, q.c-1, q.d[q.c-1].k, q, t, atomic.LoadUint64(&t.ver)), nil
}
1226148
func (itr *roaringIterator) Seek(bseek, pseek uint64) {
	itr.itr.Seek((bseek * ShardWidth) + pseek)
}
43591
func (f *followDatastoreFile) Read(p []byte) (int, error) {
	offset := f.r.offset.seek
	stop := false

	for {
		n, err := f.r.Read(p)
		if err != nil && err == io.EOF {
			_ = f.r.Close() // GET request body has been drained.
			if stop {
				return n, err
			}
			err = nil
		}

		if n > 0 {
			return n, err
		}

		select {
		case <-f.c:
			// Wake up and stop polling once the body has been drained
			stop = true
		case <-time.After(f.i):
		}

		info, serr := f.r.Stat()
		if serr != nil {
			// Return EOF rather than 404 if the file goes away
			if serr == os.ErrNotExist {
				_ = f.r.Close()
				return 0, io.EOF
			}
			return 0, serr
		}

		if info.Size() < offset {
			// assume file has be truncated
			offset, err = f.r.Seek(0, io.SeekStart)
			if err != nil {
				return 0, err
			}
		}
	}
}
1181736
func (c *index) SeekFirst(r kv.Retriever) (iter table.IndexIterator, err error) {
	upperBound := c.prefix.PrefixNext()
	it, err := r.Iter(c.prefix, upperBound)
	if err != nil {
		return nil, err
	}
	return &indexIter{it: it, idx: c, prefix: c.prefix}, nil
}
191751
func (o *LargeObject) Seek(offset int64, whence int) (n int64, err error) {
	if o.lo.Has64 {
		n, err = fpInt64(o.lo.fp.CallFn("lo_lseek64", []fpArg{fpIntArg(o.fd), fpInt64Arg(offset), fpIntArg(int32(whence))}))
	} else {
		var n32 int32
		n32, err = fpInt32(o.lo.fp.CallFn("lo_lseek", []fpArg{fpIntArg(o.fd), fpIntArg(int32(offset)), fpIntArg(int32(whence))}))
		n = int64(n32)
	}
	return
}
348723
func (t *tree) Seek(k uint64) (e *enumerator, ok bool) {
	q := t.r
	if q == nil {
		e = btEPool.get(nil, false, 0, k, nil, t, t.ver)
		return
	}

	for {
		var i int
		if i, ok = t.find(q, k); ok {
			switch x := q.(type) {
			case *x:
				q = x.x[i+1].ch
				continue
			case *d:
				return btEPool.get(nil, ok, i, k, x, t, t.ver), true
			}
		}

		switch x := q.(type) {
		case *x:
			q = x.x[i].ch
		case *d:
			return btEPool.get(nil, ok, i, k, x, t, t.ver), false
		}
	}
}
377144
func (hr *hookReader) Seek(offset int64, whence int) (n int64, err error) {
	// Verify for source has embedded Seeker, use it.
	sourceSeeker, ok := hr.source.(io.Seeker)
	if ok {
		n, err = sourceSeeker.Seek(offset, whence)
		if err != nil {
			return 0, err
		}
	}

	// Verify if hook has embedded Seeker, use it.
	hookSeeker, ok := hr.hook.(io.Seeker)
	if ok {
		var m int64
		m, err = hookSeeker.Seek(offset, whence)
		if err != nil {
			return 0, err
		}
		if n != m {
			return 0, fmt.Errorf("hook seeker seeked %d bytes, expected source %d bytes", m, n)
		}
	}
	return n, nil
}
546137
func (reader *Reader) Seek(off dwarf.Offset) {
	reader.depth = 0
	reader.Reader.Seek(off)
}
600021
func (p *Player) Seek(offset time.Duration) error {
	o := int64(offset) * bytesPerSample * channelNum * int64(p.sampleRate) / int64(time.Second)
	o &= mask
	select {
	case p.seekCh <- seekArgs{o, io.SeekStart}:
		return <-p.seekedCh
	case <-p.readLoopEndedCh:
		return fmt.Errorf("audio: the player is already closed")
	}
}
705846
func (rwops *RWops) Seek(offset int64, whence int) (int64, error) {
	if rwops == nil {
		return -1, ErrInvalidParameters
	}

	ret := int64(C.RWseek(rwops.cptr(), C.Sint64(offset), C.int(whence)))
	if ret < 0 {
		return ret, GetError()
	}
	return ret, nil
}
135927
func (*Rar) Match(file io.ReadSeeker) (bool, error) {
	currentPos, err := file.Seek(0, io.SeekCurrent)
	if err != nil {
		return false, err
	}
	_, err = file.Seek(0, 0)
	if err != nil {
		return false, err
	}
	defer file.Seek(currentPos, io.SeekStart)

	buf := make([]byte, 8)
	if n, err := file.Read(buf); err != nil || n < 8 {
		return false, nil
	}
	hasTarHeader := bytes.Equal(buf[:7], []byte("Rar!\x1a\x07\x00")) || // ver 1.5
		bytes.Equal(buf, []byte("Rar!\x1a\x07\x01\x00")) // ver 5.0
	return hasTarHeader, nil
}
1277264
func (f FakeFile) Seek(offset int64, whence int) (int64, error) {
	return f.Buffer.Seek(offset, whence)
}
334292
func (c *Cursor) Seek(prefix []byte) ([]byte, []byte) {
	k, v := c.cursor.Seek(prefix)
	if len(v) == 0 {
		return nil, nil
	}
	return k, v
}
33340
func (r *rangeIterator) seekBeyond(target *rangeIterator) {
	r.it.seek(target.rangeMax.Next())
	if !r.it.Done() && r.it.CellID().RangeMin() <= target.rangeMax {
		r.it.Next()
	}
	r.refresh()
}
1127175
func (r *scannerReader) Seek(offset int64, whence int) (int64, error) {
	var err error

	if seeker, ok := r.reader.(io.ReadSeeker); !ok {
		if whence != io.SeekCurrent || offset != 0 {
			return -1, ErrSeekNotSupported
		}
	} else {
		if whence == io.SeekCurrent && offset == 0 {
			return r.offset, nil
		}

		r.offset, err = seeker.Seek(offset, whence)
		r.rbuf.Reset(r.reader)
	}

	return r.offset, err
}