diff options
author | Chris Wilson <chris+github@qwirx.com> | 2015-12-13 23:46:22 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2015-12-14 00:06:03 +0000 |
commit | e9ea5f21a90cca3623115a3c901d033b81f97eb6 (patch) | |
tree | ff69f071656d2656d91b247d01195b75b000b945 /lib | |
parent | 004c1d3b39f045f0f3935f6ca7cb9cb1960573ea (diff) |
Fix Windows file locking to work with MSVC
Diffstat (limited to 'lib')
-rw-r--r-- | lib/common/NamedLock.cpp | 3 | ||||
-rw-r--r-- | lib/win32/emu.cpp | 2 | ||||
-rw-r--r-- | lib/win32/emu.h | 2 |
3 files changed, 5 insertions, 2 deletions
diff --git a/lib/common/NamedLock.cpp b/lib/common/NamedLock.cpp index 8cacf065..e440408e 100644 --- a/lib/common/NamedLock.cpp +++ b/lib/common/NamedLock.cpp @@ -82,6 +82,9 @@ bool NamedLock::TryAndGetLock(const std::string& rFilename, int mode) #if HAVE_DECL_O_EXLOCK flags |= O_NONBLOCK | O_EXLOCK; BOX_TRACE("Trying to create lockfile " << rFilename << " using O_EXLOCK"); +#elif defined BOX_OPEN_LOCK + flags |= BOX_OPEN_LOCK; + BOX_TRACE("Trying to create lockfile " << rFilename << " using BOX_OPEN_LOCK"); #elif !HAVE_DECL_F_SETLK && !defined HAVE_FLOCK // We have no other way to get a lock, so all we can do is fail if // the file already exists, and take the risk of stale locks. diff --git a/lib/win32/emu.cpp b/lib/win32/emu.cpp index 658bfbbc..65c12b09 100644 --- a/lib/win32/emu.cpp +++ b/lib/win32/emu.cpp @@ -613,7 +613,7 @@ HANDLE openfile(const char *pFileName, int flags, int mode) createDisposition = CREATE_NEW; } - if (flags & O_LOCK) + if (flags & BOX_OPEN_LOCK) { shareMode = 0; } diff --git a/lib/win32/emu.h b/lib/win32/emu.h index 8014316a..80c1d5d8 100644 --- a/lib/win32/emu.h +++ b/lib/win32/emu.h @@ -224,7 +224,7 @@ struct dirent *readdir(DIR *dp); int closedir(DIR *dp); // local constant to open file exclusively without shared access -#define O_LOCK 0x10000 +#define BOX_OPEN_LOCK 0x10000 extern DWORD winerrno; /* used to report errors from openfile() */ HANDLE openfile(const char *filename, int flags, int mode); |