Skip to content

Commit d4999d4

Browse files
committed
util: Revert back MoveFileExW call for MinGW-w64
1 parent 25a91a5 commit d4999d4

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/util/system.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,9 +1062,20 @@ void ArgsManager::LogArgs() const
10621062

10631063
bool RenameOver(fs::path src, fs::path dest)
10641064
{
1065+
#ifdef __MINGW64__
1066+
// This is a workaround for a bug in libstdc++ which
1067+
// implements std::filesystem::rename with _wrename function.
1068+
// This bug has been fixed in upstream:
1069+
// - GCC 10.3: 8dd1c1085587c9f8a21bb5e588dfe1e8cdbba79e
1070+
// - GCC 11.1: 1dfd95f0a0ca1d9e6cbc00e6cbfd1fa20a98f312
1071+
// For more details see the commits mentioned above.
1072+
return MoveFileExW(src.wstring().c_str(), dest.wstring().c_str(),
1073+
MOVEFILE_REPLACE_EXISTING) != 0;
1074+
#else
10651075
std::error_code error;
10661076
fs::rename(src, dest, error);
10671077
return !error;
1078+
#endif
10681079
}
10691080

10701081
/**

0 commit comments

Comments
 (0)