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

Function CopyFile

pkg/fileutil/fileutil.go:164–185  ·  view source on GitHub ↗

CopyFile copies a file from src to dst using buffered IO.

(src, dst string)

Source from the content-addressed store, hash-verified

162
163// CopyFile copies a file from src to dst using buffered IO.
164func CopyFile(src, dst string) error {
165 fileutilLog.Printf("Copying file: src=%s, dst=%s", src, dst)
166 in, err := os.Open(src)
167 if err != nil {
168 fileutilLog.Printf("Failed to open source file: %s", err)
169 return err
170 }
171 defer in.Close()
172
173 out, err := os.Create(dst)
174 if err != nil {
175 fileutilLog.Printf("Failed to create destination file: %s", err)
176 return err
177 }
178 err = copyFileContents(in, out, dst)
179 if err != nil {
180 return err
181 }
182
183 fileutilLog.Printf("File copied successfully: src=%s, dst=%s", src, dst)
184 return nil
185}

Callers 9

extractLogMetricsFunction · 0.92
TestMainFunction · 0.92
setupIntegrationTestFunction · 0.92
setupAddIntegrationTestFunction · 0.92
TestCopyFileFunction · 0.85

Calls 3

copyFileContentsFunction · 0.85
CloseMethod · 0.65
PrintfMethod · 0.45

Tested by 7

TestMainFunction · 0.74
setupIntegrationTestFunction · 0.74
setupAddIntegrationTestFunction · 0.74
TestCopyFileFunction · 0.68