| 1 | //go:build windows |
| 2 | |
| 3 | package fileutil |
| 4 | |
| 5 | import ( |
| 6 | "errors" |
| 7 | "syscall" |
| 8 | |
| 9 | "golang.org/x/sys/windows" |
| 10 | ) |
| 11 | |
| 12 | // renameCrossesDevice reports whether a rename failed because the filesystem |
| 13 | // treats the two paths as different devices. Encryption-software filter |
| 14 | // drivers report ERROR_NOT_SAME_DEVICE even for a same-directory rename |
| 15 | // (#2696); such a rename fails identically on every retry, so ReplaceFile |
| 16 | // goes straight to its copy fallback instead of burning the retry backoff. |
| 17 | func renameCrossesDevice(err error) bool { |
| 18 | return errors.Is(err, windows.ERROR_NOT_SAME_DEVICE) || errors.Is(err, syscall.EXDEV) |
| 19 | } |
| 20 |