MCPcopy Index your code
hub / github.com/bitfield/script / writeOrAppendFile

Method writeOrAppendFile

script.go:1023–1038  ·  view source on GitHub ↗
(path string, mode int)

Source from the content-addressed store, hash-verified

1021}
1022
1023func (p *Pipe) writeOrAppendFile(path string, mode int) (int64, error) {
1024 if p.Error() != nil {
1025 return 0, p.Error()
1026 }
1027 out, err := os.OpenFile(path, mode, 0o666)
1028 if err != nil {
1029 p.SetError(err)
1030 return 0, err
1031 }
1032 defer out.Close()
1033 wrote, err := io.Copy(out, p)
1034 if err != nil {
1035 p.SetError(err)
1036 }
1037 return wrote, p.Error()
1038}
1039
1040// ReadAutoCloser wraps an [io.ReadCloser] so that it will be automatically
1041// closed once it has been fully read.

Callers 2

AppendFileMethod · 0.95
WriteFileMethod · 0.95

Calls 3

ErrorMethod · 0.95
SetErrorMethod · 0.95
CloseMethod · 0.45

Tested by

no test coverage detected