renameormove: Windows: unlink existing file before rename
This commit is contained in:
parent
84855d5241
commit
854326a0ba
@ -129,6 +129,13 @@ out:
|
|||||||
|
|
||||||
bool renameormove(const char *src, const char *dst, string &reason)
|
bool renameormove(const char *src, const char *dst, string &reason)
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Windows refuses to rename to an existing file. It appears that
|
||||||
|
// there are workarounds (See MoveFile, MoveFileTransacted), but
|
||||||
|
// anyway we are not expecting atomicity here.
|
||||||
|
unlink(dst);
|
||||||
|
#endif
|
||||||
|
|
||||||
// First try rename(2). If this succeeds we're done. If this fails
|
// First try rename(2). If this succeeds we're done. If this fails
|
||||||
// with EXDEV, try to copy. Unix really should have a library function
|
// with EXDEV, try to copy. Unix really should have a library function
|
||||||
// for this.
|
// for this.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user