(path string, mode int)
| 1021 | } |
| 1022 | |
| 1023 | func (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. |
no test coverage detected