diff options
author | Joel Rosdahl <joel@rosdahl.net> | 2020-02-22 22:04:14 +0100 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2020-02-22 22:04:14 +0100 |
commit | 14ef13c2325e0cd905aa091a52447772b52f4b6a (patch) | |
tree | 060871f97ee6a280c063202bfffb87da7c50314f | |
parent | 92145eb0762109b5f0114a6f4de2fea7d4ac016f (diff) | |
download | ccache-14ef13c2325e0cd905aa091a52447772b52f4b6a.tar.gz |
win32: Use MOVEFILE_REPLACE_EXISTING to replace file x_rename
This is a partial cherry-pick of 743f35a1.
Co-authored-by: Cristian Adam <cristian.adam@gmail.com>
-rw-r--r-- | src/util.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -1,5 +1,5 @@ // Copyright (C) 2002 Andrew Tridgell -// Copyright (C) 2009-2019 Joel Rosdahl +// Copyright (C) 2009-2020 Joel Rosdahl // // This program is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License as published by the Free @@ -1519,9 +1519,8 @@ x_rename(const char *oldpath, const char *newpath) return rename(oldpath, newpath); #else // Windows' rename() refuses to overwrite an existing file. - unlink(newpath); // Not x_unlink, as x_unlink calls x_rename. // If the function succeeds, the return value is nonzero. - if (MoveFileA(oldpath, newpath) == 0) { + if (MoveFileExA(oldpath, newpath, MOVEFILE_REPLACE_EXISTING) == 0) { LPVOID lp_msg_buf; DWORD dw = GetLastError(); FormatMessage( |