(dst, src string)
| 88 | } |
| 89 | |
| 90 | func 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 | |
| 108 | func cloneFileSyscall(dst, src string) *CloneFileError { |
| 109 | err := unix.Clonefileat(unix.AT_FDCWD, src, unix.AT_FDCWD, dst, unix.CLONE_NOFOLLOW) |
no test coverage detected