20 "Non-zero start lock regions are not supported");
22 OVERLAPPED overlapped = {};
24 if (!::LockFileEx(file_handle, flags, 0, len, 0, &overlapped) &&
25 ::GetLastError() != ERROR_IO_PENDING)
29 if (!::GetOverlappedResult(file_handle, &overlapped, &bytes, TRUE))
36 :
LockFileBase(fd), m_file(reinterpret_cast<HANDLE>(_get_osfhandle(fd))) {}
50 return fileLock(
m_file, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY,
64 OVERLAPPED overlapped = {};
66 if (!::UnlockFileEx(
m_file, 0,
m_len, 0, &overlapped) &&
67 ::GetLastError() != ERROR_IO_PENDING)
71 if (!::GetOverlappedResult(
m_file, &overlapped, &bytes, TRUE))
static Status fileLock(int fd, int cmd, int lock_type, const uint64_t start, const uint64_t len)
static Status fileLock(HANDLE file_handle, DWORD flags, const uint64_t start, const uint64_t len)
virtual bool IsValidFile() const
Status DoTryReadLock(const uint64_t start, const uint64_t len) override
bool IsValidFile() const override
Status DoWriteLock(const uint64_t start, const uint64_t len) override
Status DoUnlock() override
Status DoTryWriteLock(const uint64_t start, const uint64_t len) override
Status DoReadLock(const uint64_t start, const uint64_t len) override
static Status FromErrorString(const char *str)
A class that represents a running process on the host machine.
@ eErrorTypeWin32
Standard Win32 error codes.