From 101746f2688f0b8f66b574cd492ab41c0f7eec4f Mon Sep 17 00:00:00 2001 From: Luke Street Date: Tue, 22 Feb 2022 00:46:15 -0500 Subject: [PATCH] Common.hpp: Refactor to remove include --- include/amuse/Common.hpp | 12 ++---------- lib/Common.cpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/amuse/Common.hpp b/include/amuse/Common.hpp index 24fb08f..8466d62 100644 --- a/include/amuse/Common.hpp +++ b/include/amuse/Common.hpp @@ -18,10 +18,6 @@ #include #include #else -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN 1 -#endif -#include #include #endif @@ -344,15 +340,11 @@ typedef struct stat Sstat; static inline int Stat(const char* path, Sstat* statout) { return stat(path, statout); } #endif -inline int Rename(const char* oldpath, const char* newpath) { #if _WIN32 - const nowide::wstackstring woldpath(oldpath); - const nowide::wstackstring wnewpath(newpath); - return MoveFileExW(woldpath.get(), wnewpath.get(), MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH) == 0; +int Rename(const char* oldpath, const char* newpath); #else - return rename(oldpath, newpath); +inline int Rename(const char* oldpath, const char* newpath) { return rename(oldpath, newpath); } #endif -} inline int CompareCaseInsensitive(const char* a, const char* b) { #if _WIN32 diff --git a/lib/Common.cpp b/lib/Common.cpp index 4cb39e2..6541e81 100644 --- a/lib/Common.cpp +++ b/lib/Common.cpp @@ -3,6 +3,14 @@ #ifndef _WIN32 #include #include +#else +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include #endif #include @@ -47,6 +55,14 @@ bool Copy(const char* from, const char* to) { #endif } +#if _WIN32 +int Rename(const char* oldpath, const char* newpath) { + const nowide::wstackstring woldpath(oldpath); + const nowide::wstackstring wnewpath(newpath); + return MoveFileExW(woldpath.get(), wnewpath.get(), MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH) == 0; +} +#endif + #define DEFINE_ID_TYPE(type, typeName) \ thread_local NameDB* type::CurNameDB = nullptr; \ template <> \