-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Closed
Labels
Description
go version go1.5.2 windows/386
After 92c5736 with MoveFileEx os.Rename("r:\1.txt", "z:\1.txt") on windows generate error:
The system cannot move the file to a different disk drive
https://msdn.microsoft.com/ru-ru/library/windows/desktop/aa365240(v=vs.85).aspx
When moving a file, the destination can be on a different file system or volume. If the destination is on another drive, you must set the MOVEFILE_COPY_ALLOWED flag in dwFlags.
So, syscall_windows.go Rename must be
func Rename(oldpath, newpath string) error {
from, err := syscall.UTF16PtrFromString(oldpath)
if err != nil {
return err
}
to, err := syscall.UTF16PtrFromString(newpath)
if err != nil {
return err
}
return MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING|MOVEFILE_COPY_ALLOWED)
}