diff --git a/nav.go b/nav.go index 121cd4b4..b6c73ddc 100644 --- a/nav.go +++ b/nav.go @@ -12,7 +12,6 @@ import ( "sort" "strconv" "strings" - "syscall" "time" times "gopkg.in/djherbis/times.v1" @@ -744,7 +743,7 @@ func (nav *nav) moveAsync(ui *ui, srcs []string, dstDir string) { } if err := os.Rename(src, dst); err != nil { - if err.(*os.LinkError).Err.(syscall.Errno) == syscall.EXDEV { + if errCrossDevice(err) { total, err := copySize([]string{src}) if err != nil { echo.args[0] = err.Error() diff --git a/os.go b/os.go index 36ea097a..f54d4097 100644 --- a/os.go +++ b/os.go @@ -11,6 +11,7 @@ import ( "path/filepath" "runtime" "strings" + "syscall" ) var ( @@ -161,6 +162,10 @@ func matchPattern(pattern, name, path string) bool { return matched } +func errCrossDevice(err error) bool { + return err.(*os.LinkError).Err.(syscall.Errno) == syscall.EXDEV +} + func exportFiles(f string, fs []string) { envFile := f envFiles := strings.Join(fs, gOpts.filesep) diff --git a/os_windows.go b/os_windows.go index aef9a338..35b31fe4 100644 --- a/os_windows.go +++ b/os_windows.go @@ -119,6 +119,10 @@ func isHidden(f os.FileInfo, path string) bool { return false } +func errCrossDevice(err error) bool { + return err.(*os.LinkError).Err.(syscall.Errno) == 17 +} + func exportFiles(f string, fs []string) { envFile := fmt.Sprintf(`"%s"`, f)