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

Function CloneFileByPath

tools/util_darwin.go:90–106  ·  view source on GitHub ↗
(dst, src string)

Source from the content-addressed store, hash-verified

88}
89
90func CloneFileByPath(dst, src string) (bool, error) {
91 if !cloneFileSupported {
92 return false, &CloneFileError{Unsupported: true, errorString: tr.Tr.Get("clonefile is not supported")}
93 }
94
95 if FileExists(dst) {
96 if err := os.Remove(dst); err != nil {
97 return false, err // File should be not exists before create
98 }
99 }
100
101 if err := cloneFileSyscall(dst, src); err != nil {
102 return false, err
103 }
104
105 return true, nil
106}
107
108func cloneFileSyscall(dst, src string) *CloneFileError {
109 err := unix.Clonefileat(unix.AT_FDCWD, src, unix.AT_FDCWD, dst, unix.CLONE_NOFOLLOW)

Callers 1

CheckCloneFileSupportedFunction · 0.70

Calls 4

FileExistsFunction · 0.85
cloneFileSyscallFunction · 0.85
GetMethod · 0.65
RemoveMethod · 0.45

Tested by

no test coverage detected