cmake/Source/cmFileLockResult.h

78 lines
1.4 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2015-04-27 22:25:09 +02:00
#ifndef cmFileLockResult_h
#define cmFileLockResult_h
2017-07-20 19:35:53 +02:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-10-30 18:24:19 +01:00
#include <string>
2015-04-27 22:25:09 +02:00
#if defined(_WIN32)
2018-08-09 18:06:22 +02:00
# include <windows.h> // DWORD
2015-04-27 22:25:09 +02:00
#endif
/**
2018-08-09 18:06:22 +02:00
* @brief Result of the locking/unlocking file.
* @note See @c cmFileLock
*/
2015-04-27 22:25:09 +02:00
class cmFileLockResult
{
2016-07-09 11:21:54 +02:00
public:
2015-04-27 22:25:09 +02:00
#if defined(_WIN32)
2020-02-01 23:06:01 +01:00
using Error = DWORD;
2015-04-27 22:25:09 +02:00
#else
2020-02-01 23:06:01 +01:00
using Error = int;
2015-04-27 22:25:09 +02:00
#endif
/**
2018-08-09 18:06:22 +02:00
* @brief Successful lock/unlock.
*/
2015-04-27 22:25:09 +02:00
static cmFileLockResult MakeOk();
/**
2018-08-09 18:06:22 +02:00
* @brief Lock/Unlock failed. Read error/GetLastError.
*/
2015-04-27 22:25:09 +02:00
static cmFileLockResult MakeSystem();
/**
2018-08-09 18:06:22 +02:00
* @brief Lock/Unlock failed. Timeout reached.
*/
2015-04-27 22:25:09 +02:00
static cmFileLockResult MakeTimeout();
/**
2018-08-09 18:06:22 +02:00
* @brief File already locked.
*/
2015-04-27 22:25:09 +02:00
static cmFileLockResult MakeAlreadyLocked();
/**
2018-08-09 18:06:22 +02:00
* @brief Internal error.
*/
2015-04-27 22:25:09 +02:00
static cmFileLockResult MakeInternal();
/**
2018-08-09 18:06:22 +02:00
* @brief Try to lock with function guard outside of the function
*/
2015-04-27 22:25:09 +02:00
static cmFileLockResult MakeNoFunction();
bool IsOk() const;
std::string GetOutputMessage() const;
2016-07-09 11:21:54 +02:00
private:
2015-04-27 22:25:09 +02:00
enum ErrorType
{
OK,
SYSTEM,
TIMEOUT,
ALREADY_LOCKED,
INTERNAL,
NO_FUNCTION
};
cmFileLockResult(ErrorType type, Error errorValue);
ErrorType Type;
Error ErrorValue;
};
#endif // cmFileLockResult_h