MCPcopy
hub / github.com/docker/compose / Write

Method Write

pkg/compose/logs_test.go:57–80  ·  view source on GitHub ↗
(p []byte)

Source from the content-addressed store, hash-verified

55}
56
57func (w *stdWriter) Write(p []byte) (int, error) {
58 if w == nil || w.Writer == nil {
59 return 0, errors.New("writer not instantiated")
60 }
61 if p == nil {
62 return 0, nil
63 }
64
65 header := [stdWriterPrefixLen]byte{stdWriterFdIndex: w.prefix}
66 binary.BigEndian.PutUint32(header[stdWriterSizeIndex:], uint32(len(p)))
67 buf := bufPool.Get().(*bytes.Buffer)
68 buf.Write(header[:])
69 buf.Write(p)
70
71 n, err := w.Writer.Write(buf.Bytes())
72 n -= stdWriterPrefixLen
73 if n < 0 {
74 n = 0
75 }
76
77 buf.Reset()
78 bufPool.Put(buf)
79 return n, err
80}
81
82func newStdWriter(w io.Writer, streamType stdcopy.StdType) io.Writer {
83 return &stdWriter{

Callers 2

createTarFunction · 0.45

Calls 1

BytesMethod · 0.80

Tested by

no test coverage detected