# # # patch "ChangeLog" # from [2e2a8c028a362b9d8ff98207b8e500136e92b2c4] # to [bbf06154de0f1e7ff9c99694d8b3c03a6aff7c28] # # patch "win32/fs.cc" # from [f62b995744f75235f82ae3d6ce7e3ae66a5b8c73] # to [0dc1c6a7dcf5bb4552c96aca16faaf7cea90c434] # ============================================================ --- ChangeLog 2e2a8c028a362b9d8ff98207b8e500136e92b2c4 +++ ChangeLog bbf06154de0f1e7ff9c99694d8b3c03a6aff7c28 @@ -1,3 +1,7 @@ +2007-02-07 Matthew Gregan + + * win32/fs.cc (rename_clobberingly_impl): GNU style. + 2007-02-07 Derek Scherger * commands.cc: ============================================================ --- win32/fs.cc f62b995744f75235f82ae3d6ce7e3ae66a5b8c73 +++ win32/fs.cc 0dc1c6a7dcf5bb4552c96aca16faaf7cea90c434 @@ -139,38 +139,45 @@ static bool } static bool -rename_clobberingly_impl(const char* from, const char* to) +rename_clobberingly_impl(const char * from, const char * to) { // MoveFileEx is only available on NT-based systems. We will revert to a // more compatible DeleteFile/MoveFile pair as a compatibility fall-back. typedef BOOL (WINAPI *MoveFileExFun)(LPCTSTR, LPCTSTR, DWORD); static MoveFileExFun fnMoveFileEx = 0; static bool MoveFileExAvailable = false; - if (fnMoveFileEx == 0) { - HMODULE hModule = LoadLibrary("kernel32"); - if (hModule) - fnMoveFileEx = reinterpret_cast - (GetProcAddress(hModule, "MoveFileExA")); - if (fnMoveFileEx) { - L(FL("using MoveFileEx for renames")); - MoveFileExAvailable = true; - } else - L(FL("using DeleteFile/MoveFile fallback for renames")); - } + if (fnMoveFileEx == 0) + { + HMODULE hModule = LoadLibrary("kernel32"); + if (hModule) + fnMoveFileEx = reinterpret_cast + (GetProcAddress(hModule, "MoveFileExA")); + if (fnMoveFileEx) + { + L(FL("using MoveFileEx for renames")); + MoveFileExAvailable = true; + } + else + L(FL("using DeleteFile/MoveFile fallback for renames")); + } - if (MoveFileExAvailable) { - if (fnMoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING)) - return true; - else if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) { - MoveFileExAvailable = false; - L(FL("MoveFileEx failed with CALL_NOT_IMPLEMENTED, using fallback")); + if (MoveFileExAvailable) + { + if (fnMoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING)) + return true; + else if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) + { + MoveFileExAvailable = false; + L(FL("MoveFileEx failed with CALL_NOT_IMPLEMENTED, using fallback")); + } } - } else { - // This is not even remotely atomic, but what can you do? - DeleteFile(to); - if (MoveFile(from, to)) - return true; - } + else + { + // This is not even remotely atomic, but what can you do? + DeleteFile(to); + if (MoveFile(from, to)) + return true; + } return false; }