12#include <sys/utsname.h>
25FILE *
fopen(
const fs::path& p,
const char *mode)
34fs::path
AbsPathJoin(
const fs::path& base,
const fs::path& path)
36 assert(base.is_absolute());
37 return path.empty() ? base : fs::path(base / path);
49 fd = open(file.c_str(), O_RDWR);
69 lock.l_type = F_WRLCK;
70 lock.l_whence = SEEK_SET;
73 if (fcntl(
fd, F_SETLK, &lock) == -1) {
83 return Win32ErrorString(GetLastError());
88 hFile = CreateFileW(file.wstring().c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
89 nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
nullptr);
90 if (hFile == INVALID_HANDLE_VALUE) {
97 if (hFile != INVALID_HANDLE_VALUE) {
104 if (hFile == INVALID_HANDLE_VALUE) {
107 _OVERLAPPED overlapped = {};
108 if (!LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY, 0, std::numeric_limits<DWORD>::max(), std::numeric_limits<DWORD>::max(), &overlapped)) {
Bridge operations to C stdio.
FILE * fopen(const fs::path &p, const char *mode)
fs::path AbsPathJoin(const fs::path &base, const fs::path &path)
Helper function for joining two paths.
static std::string GetErrorReason()
std::string SysErrorString(int err)
Return system error string from errno value.