cmFileLockResult: Remove expensive windows.h include

This commit is contained in:
Clemens Wasser
2023-06-16 19:22:11 +02:00
parent 870390ee81
commit 64821d8a26
3 changed files with 6 additions and 18 deletions

View File

@@ -12,11 +12,7 @@
cmFileLock::cmFileLock(cmFileLock&& other) noexcept cmFileLock::cmFileLock(cmFileLock&& other) noexcept
{ {
this->File = other.File; this->File = other.File;
#if defined(_WIN32) other.File = (decltype(other.File))-1;
other.File = INVALID_HANDLE_VALUE;
#else
other.File = -1;
#endif
this->Filename = std::move(other.Filename); this->Filename = std::move(other.Filename);
} }
@@ -32,11 +28,7 @@ cmFileLock::~cmFileLock()
cmFileLock& cmFileLock::operator=(cmFileLock&& other) noexcept cmFileLock& cmFileLock::operator=(cmFileLock&& other) noexcept
{ {
this->File = other.File; this->File = other.File;
#if defined(_WIN32) other.File = (decltype(other.File))-1;
other.File = INVALID_HANDLE_VALUE;
#else
other.File = -1;
#endif
this->Filename = std::move(other.Filename); this->Filename = std::move(other.Filename);
return *this; return *this;

View File

@@ -5,6 +5,10 @@
#include <cerrno> #include <cerrno>
#include <cstring> #include <cstring>
#ifdef _WIN32
# include <Windows.h>
#endif
cmFileLockResult cmFileLockResult::MakeOk() cmFileLockResult cmFileLockResult::MakeOk()
{ {
return { OK, 0 }; return { OK, 0 };

View File

@@ -6,10 +6,6 @@
#include <string> #include <string>
#if defined(_WIN32)
# include <windows.h> // DWORD
#endif
/** /**
* @brief Result of the locking/unlocking file. * @brief Result of the locking/unlocking file.
* @note See @c cmFileLock * @note See @c cmFileLock
@@ -17,11 +13,7 @@
class cmFileLockResult class cmFileLockResult
{ {
public: public:
#if defined(_WIN32)
using Error = DWORD;
#else
using Error = int; using Error = int;
#endif
/** /**
* @brief Successful lock/unlock. * @brief Successful lock/unlock.