Add lock file
This commit is contained in:
parent
c2d0033f78
commit
4aa3194e00
2 changed files with 37 additions and 0 deletions
19
src/utils/lock_file.hpp
Normal file
19
src/utils/lock_file.hpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace utils::filesystem {
|
||||
class LockFile {
|
||||
public:
|
||||
LockFile(std::string path) : path_(std::move(path) + ".lock") {}
|
||||
|
||||
void Lock();
|
||||
void lock() { Lock(); }
|
||||
|
||||
void Unlock();
|
||||
void unlock() { Unlock(); }
|
||||
|
||||
private:
|
||||
std::string path_;
|
||||
int fd_ = -1;
|
||||
};
|
||||
} // namespace utils::filesystem
|
Loading…
Add table
Add a link
Reference in a new issue