MCPcopy Create free account
hub / github.com/github/gh-aw / copyFileContents

Function copyFileContents

pkg/fileutil/fileutil.go:141–161  ·  view source on GitHub ↗
(in io.Reader, out syncWriteCloser, dst string)

Source from the content-addressed store, hash-verified

139}
140
141func copyFileContents(in io.Reader, out syncWriteCloser, dst string) (err error) {
142 removePartial := false
143
144 defer func() {
145 if closeErr := out.Close(); closeErr != nil && err == nil {
146 err = closeErr
147 }
148 if removePartial {
149 if removeErr := os.Remove(dst); removeErr != nil {
150 fileutilLog.Printf("Failed to remove partial destination file during cleanup: %s", removeErr)
151 }
152 }
153 }()
154
155 if _, err = io.Copy(out, in); err != nil {
156 removePartial = true
157 return err
158 }
159
160 return out.Sync()
161}
162
163// CopyFile copies a file from src to dst using buffered IO.
164func CopyFile(src, dst string) error {

Callers 2

TestCopyFileContentsFunction · 0.85
CopyFileFunction · 0.85

Calls 3

CloseMethod · 0.65
SyncMethod · 0.65
PrintfMethod · 0.45

Tested by 1

TestCopyFileContentsFunction · 0.68