19 return Status(
"Non-zero start lock regions are not supported");
21 OVERLAPPED overlapped = {};
23 if (!::LockFileEx(file_handle, flags, 0, len, 0, &overlapped) &&
24 ::GetLastError() != ERROR_IO_PENDING)
28 if (!::GetOverlappedResult(file_handle, &overlapped, &bytes, TRUE))
35 :
LockFileBase(fd), m_file(reinterpret_cast<HANDLE>(_get_osfhandle(fd))) {}
49 return fileLock(
m_file, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY,
63 OVERLAPPED overlapped = {};
65 if (!::UnlockFileEx(
m_file, 0,
m_len, 0, &overlapped) &&
66 ::GetLastError() != ERROR_IO_PENDING)
70 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
A class that represents a running process on the host machine.
@ eErrorTypeWin32
Standard Win32 error codes.