MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / Seek

Method Seek

asyncbuffer/reader.go:26–54  ·  view source on GitHub ↗

Seek sets the position of the reader to the given offset and returns the new position

(offset int64, whence int)

Source from the content-addressed store, hash-verified

24
25// Seek sets the position of the reader to the given offset and returns the new position
26func (r *Reader) Seek(offset int64, whence int) (int64, error) {
27 switch whence {
28 case io.SeekStart:
29 r.pos = offset
30
31 case io.SeekCurrent:
32 r.pos += offset
33
34 case io.SeekEnd:
35 size := r.ab.dataLen
36 if size <= 0 {
37 var err error
38 if size, err = r.ab.Wait(); err != nil {
39 return 0, err
40 }
41 }
42
43 r.pos = int64(size) + offset
44
45 default:
46 return 0, errors.New("asyncbuffer.AsyncBuffer.ReadAt: invalid whence")
47 }
48
49 if r.pos < 0 {
50 return 0, errors.New("asyncbuffer.AsyncBuffer.ReadAt: negative position")
51 }
52
53 return r.pos, nil
54}

Callers 4

imgproxyReaderSeekFunction · 0.80
TestAsyncBufferReaderFunction · 0.80
GetObjectMethod · 0.80
detectContentTypeFunction · 0.80

Calls 1

WaitMethod · 0.45

Tested by 1

TestAsyncBufferReaderFunction · 0.64