summaryrefslogtreecommitdiffstats
path: root/Source/cmFileLockWin32.cxx
diff options
context:
space:
mode:
authorKitware Robot <kwrobot@kitware.com>2016-05-16 14:34:04 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-16 20:05:19 (GMT)
commitd9fd2f5402eeaa345691313658e02b51038f570b (patch)
treedca71b9a7e267f4c6300da3eb770415381726785 /Source/cmFileLockWin32.cxx
parent82df6deaafb36cbbfd450202bb20b320f637751a (diff)
downloadCMake-d9fd2f5402eeaa345691313658e02b51038f570b.zip
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.bz2
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update all our C++ code to a new style defined by `.clang-format`. Use `clang-format` version 3.8. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
Diffstat (limited to 'Source/cmFileLockWin32.cxx')
-rw-r--r--Source/cmFileLockWin32.cxx83
1 files changed, 26 insertions, 57 deletions
diff --git a/Source/cmFileLockWin32.cxx b/Source/cmFileLockWin32.cxx
index e40ae2c..0ba1e9a 100644
--- a/Source/cmFileLockWin32.cxx
+++ b/Source/cmFileLockWin32.cxx
@@ -15,40 +15,32 @@
#include "cmSystemTools.h"
#include <windows.h> // CreateFileW
-cmFileLock::cmFileLock(): File(INVALID_HANDLE_VALUE)
+cmFileLock::cmFileLock()
+ : File(INVALID_HANDLE_VALUE)
{
}
cmFileLockResult cmFileLock::Release()
{
- if (this->Filename.empty())
- {
+ if (this->Filename.empty()) {
return cmFileLockResult::MakeOk();
- }
+ }
const unsigned long len = static_cast<unsigned long>(-1);
static OVERLAPPED overlapped;
const DWORD reserved = 0;
- const BOOL unlockResult = UnlockFileEx(
- File,
- reserved,
- len,
- len,
- &overlapped
- );
+ const BOOL unlockResult =
+ UnlockFileEx(File, reserved, len, len, &overlapped);
this->Filename = "";
CloseHandle(this->File);
this->File = INVALID_HANDLE_VALUE;
- if (unlockResult)
- {
+ if (unlockResult) {
return cmFileLockResult::MakeOk();
- }
- else
- {
+ } else {
return cmFileLockResult::MakeSystem();
- }
+ }
}
cmFileLockResult cmFileLock::OpenFile()
@@ -59,58 +51,42 @@ cmFileLockResult cmFileLock::OpenFile()
const DWORD attr = 0;
const HANDLE templ = NULL;
this->File = CreateFileW(
- cmSystemTools::ConvertToWindowsExtendedPath(this->Filename).c_str(),
- access,
- shareMode,
- security,
- OPEN_EXISTING,
- attr,
- templ
- );
- if (this->File == INVALID_HANDLE_VALUE)
- {
+ cmSystemTools::ConvertToWindowsExtendedPath(this->Filename).c_str(),
+ access, shareMode, security, OPEN_EXISTING, attr, templ);
+ if (this->File == INVALID_HANDLE_VALUE) {
return cmFileLockResult::MakeSystem();
- }
- else
- {
+ } else {
return cmFileLockResult::MakeOk();
- }
+ }
}
cmFileLockResult cmFileLock::LockWithoutTimeout()
{
- if (!this->LockFile(LOCKFILE_EXCLUSIVE_LOCK))
- {
+ if (!this->LockFile(LOCKFILE_EXCLUSIVE_LOCK)) {
return cmFileLockResult::MakeSystem();
- }
- else
- {
+ } else {
return cmFileLockResult::MakeOk();
- }
+ }
}
cmFileLockResult cmFileLock::LockWithTimeout(unsigned long seconds)
{
const DWORD flags = LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY;
- while (true)
- {
+ while (true) {
const BOOL result = this->LockFile(flags);
- if (result)
- {
+ if (result) {
return cmFileLockResult::MakeOk();
- }
+ }
const DWORD error = GetLastError();
- if (error != ERROR_LOCK_VIOLATION)
- {
+ if (error != ERROR_LOCK_VIOLATION) {
return cmFileLockResult::MakeSystem();
- }
- if (seconds == 0)
- {
+ }
+ if (seconds == 0) {
return cmFileLockResult::MakeTimeout();
- }
+ }
--seconds;
cmSystemTools::Delay(1000);
- }
+ }
}
BOOL cmFileLock::LockFile(DWORD flags)
@@ -118,12 +94,5 @@ BOOL cmFileLock::LockFile(DWORD flags)
const DWORD reserved = 0;
const unsigned long len = static_cast<unsigned long>(-1);
static OVERLAPPED overlapped;
- return LockFileEx(
- this->File,
- flags,
- reserved,
- len,
- len,
- &overlapped
- );
+ return LockFileEx(this->File, flags, reserved, len, len, &overlapped);
}