MCPcopy Create free account
hub / github.com/crawl/crawl / lock_file

Function lock_file

crawl-ref/source/syscalls.cc:85–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83#endif
84
85bool lock_file(int fd, bool write, bool wait)
86{
87#ifdef TARGET_OS_WINDOWS
88 OVERLAPPED pos;
89 pos.hEvent = 0;
90 pos.Offset = 0;
91 pos.OffsetHigh = 0;
92 return !!LockFileEx((HANDLE)_get_osfhandle(fd),
93 (write ? LOCKFILE_EXCLUSIVE_LOCK : 0) |
94 (wait ? 0 : LOCKFILE_FAIL_IMMEDIATELY),
95 0, -1, -1, &pos);
96#else
97 struct flock fl;
98 fl.l_type = write ? F_WRLCK : F_RDLCK;
99 fl.l_whence = SEEK_SET;
100 fl.l_start = 0;
101 fl.l_len = 0;
102
103 return !fcntl(fd, wait ? F_SETLKW : F_SETLK, &fl);
104#endif
105}
106
107bool unlock_file(int fd)
108{

Callers 3

packageMethod · 0.85
lock_file_handleFunction · 0.85
lk_open_exclusiveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected