11static inline int flock(
int fd,
int operation)
13 HANDLE h = (HANDLE)_get_osfhandle(fd);
17 if (operation & LOCK_NB)
18 flags |= LOCKFILE_FAIL_IMMEDIATELY;
19 if (operation & LOCK_EX)
20 flags |= LOCKFILE_EXCLUSIVE_LOCK;
22 if (operation & LOCK_UN) {
23 return UnlockFileEx(h, 0, MAXDWORD, MAXDWORD, &o) ? 0 : -1;
25 return LockFileEx(h, flags, 0, MAXDWORD, MAXDWORD, &o) ? 0 : -1;
39 [[maybe_unused]]
int flags = O_RDWR | O_CREAT,
40 [[maybe_unused]] mode_t mode = 0644)
43 fd = open(std::string(path).c_str(), flags, mode);
FileLockGuard(std::string_view path, int flags=O_RDWR|O_CREAT, mode_t mode=0644)
FileLockGuard & operator=(const FileLockGuard &)=delete
FileLockGuard(const FileLockGuard &)=delete