Lock or unlock the entire file as specified by |lock|. Returns true when successful, false upon failure. Caller should call ::GetLastError() to determine cause of failure
| 346 | // when successful, false upon failure. Caller should call ::GetLastError() |
| 347 | // to determine cause of failure |
| 348 | bool LockOrUnlock(HANDLE handle, bool lock) { |
| 349 | if (lock) { |
| 350 | return ::LockFile(handle, |
| 351 | /*dwFileOffsetLow=*/0, /*dwFileOffsetHigh=*/0, |
| 352 | /*nNumberOfBytesToLockLow=*/MAXDWORD, |
| 353 | /*nNumberOfBytesToLockHigh=*/MAXDWORD); |
| 354 | } else { |
| 355 | return ::UnlockFile(handle, |
| 356 | /*dwFileOffsetLow=*/0, /*dwFileOffsetHigh=*/0, |
| 357 | /*nNumberOfBytesToLockLow=*/MAXDWORD, |
| 358 | /*nNumberOfBytesToLockHigh=*/MAXDWORD); |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | class WindowsFileLock : public FileLock { |
| 363 | public: |
no test coverage detected