From: Joel Rosdahl Date: Wed, 29 Jul 2020 06:43:21 +0000 (+0200) Subject: Rename win32compat to Win32Util X-Git-Tag: v4.0~265 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5a4c7d45456b1f1a6d57ae749b5254345066c9c5;p=thirdparty%2Fccache.git Rename win32compat to Win32Util --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2a24a2083..f28c192a9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -47,7 +47,7 @@ if(INODE_CACHE_SUPPORTED) endif() if(WIN32) - list(APPEND source_files win32compat.cpp) + list(APPEND source_files Win32Util.cpp) endif() add_library(ccache_lib STATIC ${source_files}) diff --git a/src/Lockfile.cpp b/src/Lockfile.cpp index e1fe22579..e07d0c2c7 100644 --- a/src/Lockfile.cpp +++ b/src/Lockfile.cpp @@ -23,7 +23,7 @@ #include "logging.hpp" #ifdef _WIN32 -# include "win32compat.hpp" +# include "Win32Util.hpp" #endif #include "third_party/fmt/core.h" @@ -154,7 +154,7 @@ do_acquire_win32(const std::string& lockfile, uint32_t staleness_limit) DWORD error = GetLastError(); cc_log("lockfile_acquire: CreateFile %s: %s (%lu)", lockfile.c_str(), - win32_error_message(error).c_str(), + Win32Util::error_message(error).c_str(), error); if (error == ERROR_PATH_NOT_FOUND) { // Directory doesn't exist? diff --git a/src/Util.cpp b/src/Util.cpp index d82a5fa11..6e1d55633 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -37,10 +37,6 @@ # include #endif -#ifdef _WIN32 -# include "win32compat.hpp" -#endif - #ifdef __linux__ # ifdef HAVE_SYS_IOCTL_H # include diff --git a/src/win32compat.cpp b/src/Win32Util.cpp similarity index 92% rename from src/win32compat.cpp rename to src/Win32Util.cpp index 27d9a6bb3..f046153fa 100644 --- a/src/win32compat.cpp +++ b/src/Win32Util.cpp @@ -16,12 +16,12 @@ // this program; if not, write to the Free Software Foundation, Inc., 51 // Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -#include "win32compat.hpp" +#include "Win32Util.hpp" -#ifdef _WIN32 +namespace Win32Util { std::string -win32_error_message(DWORD error_code) +error_message(DWORD error_code) { LPSTR buffer; size_t size = @@ -38,4 +38,4 @@ win32_error_message(DWORD error_code) return message; } -#endif +} // namespace Win32Util diff --git a/src/win32compat.hpp b/src/Win32Util.hpp similarity index 86% rename from src/win32compat.hpp rename to src/Win32Util.hpp index 252b25972..3a7ed1c9f 100644 --- a/src/win32compat.hpp +++ b/src/Win32Util.hpp @@ -22,7 +22,8 @@ #include -std::string win32_error_message(DWORD error_code); +namespace Win32Util { -BOOL -GetFileNameFromHandle(HANDLE file_handle, TCHAR* filename, WORD cch_filename); +std::string error_message(DWORD error_code); + +} // namespace Win32Util diff --git a/src/execute.cpp b/src/execute.cpp index e444a70cd..89096aaaf 100644 --- a/src/execute.cpp +++ b/src/execute.cpp @@ -30,7 +30,7 @@ #include "logging.hpp" #ifdef _WIN32 -# include "win32compat.hpp" +# include "Win32Util.hpp" #endif using nonstd::string_view; @@ -229,10 +229,9 @@ win32execute(const char* path, free(args); if (ret == 0) { DWORD error = GetLastError(); - std::string error_message = win32_error_message(error); cc_log("failed to execute %s: %s (%lu)", full_path_win_ext, - win32_error_message(error).c_str(), + Win32Util::error_message(error).c_str(), error); return -1; } diff --git a/src/legacy_util.cpp b/src/legacy_util.cpp index 07629c590..fe7cbd94b 100644 --- a/src/legacy_util.cpp +++ b/src/legacy_util.cpp @@ -24,7 +24,7 @@ #include "logging.hpp" #ifdef _WIN32 -# include "win32compat.hpp" +# include "Win32Util.hpp" #endif #ifdef HAVE_PWD_H @@ -170,7 +170,7 @@ x_rename(const char* oldpath, const char* newpath) cc_log("failed to rename %s to %s: %s (%lu)", oldpath, newpath, - win32_error_message(error).c_str(), + Win32Util::error_message(error).c_str(), error); return -1; } else {