14 #include <sys/types.h>
22 throw std::runtime_error(
"FileLock \"" +
path_.native() +
23 "\" was already acquired.");
28 open(
path_.native().c_str(), O_EXCL | O_CREAT, S_IRUSR | S_IWUSR);
34 throw std::runtime_error(
"Could not close file lock.");
bool acquired_
Whether the lock has been acquired.
FileLock(const bf::path &path)
Construct a file lock guard with a lock file at the given path.
bool acquire()
Try to acquire the file lock.
bf::path path_
Path to the file lock.
~FileLock()
Delete the lock file when the guard is destroyed.