MCPcopy
hub / github.com/lxzan/gws / WriteTo

Method WriteTo

writefile.go:207–226  ·  view source on GitHub ↗

WriteTo 写入内容, 并更新字典 Write the contents, and update the dictionary

(w io.Writer)

Source from the content-addressed store, hash-verified

205// WriteTo 写入内容, 并更新字典
206// Write the contents, and update the dictionary
207func (c *readerWrapper) WriteTo(w io.Writer) (int64, error) {
208 var buf = binaryPool.Get(segmentSize)
209 defer binaryPool.Put(buf)
210
211 var p = buf.Bytes()[:segmentSize]
212 var sum, n = 0, 0
213 var err error
214 for n, err = c.r.Read(p); err == nil || errors.Is(err, io.EOF); n, err = c.r.Read(p) {
215 eof := errors.Is(err, io.EOF)
216 if _, err = w.Write(p[:n]); err != nil {
217 return int64(sum), err
218 }
219 sum += n
220 _, _ = c.sw.Write(p[:n])
221 if eof {
222 break
223 }
224 }
225 return int64(sum), err
226}

Callers

nothing calls this directly

Calls 5

GetMethod · 0.45
PutMethod · 0.45
BytesMethod · 0.45
ReadMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected