-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
os: Rename("oldDir", "newExistingDir") doesn't work on Windows #14527
Comments
/cc @alexbrainman |
Thanks |
Note that on GNU/Linux the os.Rename will only succeed if the destination directory is empty. If the destination directory has any files it will fail with ENOTEMPTY. I think we should consider checking for and rejecting rename to an existing directory on non-Windows. |
@bradfitz, latest change (CL 6140) of windows os.Rename introduced use of MoveFileEx. Our code uses MOVEFILE_REPLACE_EXISTING flag, I guess, to make "overwriting of destination file" work. But according to the doco https://msdn.microsoft.com/en-us/library/windows/desktop/aa365240(v=vs.85).aspx:
That is why, I guess, MoveFileEx return ERROR_ACCESS_DENIED in that scenario. (Running example above I see MoveFileEx return ERROR_ACCESS_DENIED). I will let you decide what to do here. Alex |
@alexbrainman is there anything blocking this? can I be of any help? |
No, not really. Someone needs to come up with solution to this problem. I am not looking at this.
Feel free to propose solution to this. Alex |
CL https://golang.org/cl/31358 mentions this issue. |
go version
)?1.5.3
go env
)?windows - amd64
Rename a folder to new name that is already a folder. It works fine on linux-amd64 but cause error on windows-amd64
http://play.golang.org/p/m__tRp4mZh
Replacement of newDir on windows as it does on linux.
Error. Access denied. Even running as administrator!
The text was updated successfully, but these errors were encountered: