fix(util/file_lock): issue on Windows
This commit is contained in:
parent
a358ea32ac
commit
7e0612306f
1 changed files with 8 additions and 0 deletions
|
|
@ -96,9 +96,17 @@ file_lock::file_lock(char const * fname, bool exclusive):
|
|||
file_lock::~file_lock() {
|
||||
#if !defined(LEAN_EMSCRIPTEN)
|
||||
if (m_fd != -1) {
|
||||
#if !defined(LEAN_WINDOWS)
|
||||
/* On Windows, we cannot remove the file if it is locked. */
|
||||
std::remove(m_fname.c_str());
|
||||
#endif
|
||||
flock(m_fd, LOCK_UN);
|
||||
close(m_fd);
|
||||
#if defined(LEAN_WINDOWS)
|
||||
/* On Windows, we (to) to remove the file after we released the lock. The operation will fail if another
|
||||
process has a handle to it. However, this is better than always keeping all .lock files. */
|
||||
std::remove(m_fname.c_str());
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue