MCPcopy
hub / github.com/git-lfs/git-lfs / copyFile

Function copyFile

git/githistory/fixtures_test.go:206–229  ·  view source on GitHub ↗

copyFile copies a file from "from" to "to" preserving permissions and ownership.

(from, to string)

Source from the content-addressed store, hash-verified

204// copyFile copies a file from "from" to "to" preserving permissions and
205// ownership.
206func copyFile(from, to string) error {
207 src, err := os.Open(from)
208 if err != nil {
209 return err
210 }
211 defer src.Close()
212
213 dst, err := os.Create(to)
214 if err != nil {
215 return err
216 }
217 defer dst.Close()
218
219 if _, err = io.Copy(dst, src); err != nil {
220 return err
221 }
222
223 stat, err := os.Stat(from)
224 if err != nil {
225 return err
226 }
227
228 return os.Chmod(to, stat.Mode())
229}

Callers 1

copyDirFunction · 0.85

Calls 2

ModeMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected