MCPcopy Create free account
hub / github.com/docker/cli / Read

Method Read

cli/context/store/io_utils.go:15–29  ·  view source on GitHub ↗

Read is a fork of [io.LimitedReader.Read] that returns an error when limit exceeded.

(p []byte)

Source from the content-addressed store, hash-verified

13
14// Read is a fork of [io.LimitedReader.Read] that returns an error when limit exceeded.
15func (l *limitedReader) Read(p []byte) (n int, err error) {
16 if l.N < 0 {
17 return 0, errors.New("read exceeds the defined limit")
18 }
19 if l.N == 0 {
20 return 0, io.EOF
21 }
22 // have to cap N + 1 otherwise we won't hit limit err
23 if int64(len(p)) > l.N+1 {
24 p = p[0 : l.N+1]
25 }
26 n, err = l.R.Read(p)
27 l.N -= int64(n)
28 return n, err
29}

Callers 1

TestExportImportFunction · 0.45

Calls

no outgoing calls

Tested by 1

TestExportImportFunction · 0.36