23FILE *
fopen(
const fs::path& p,
const char *mode)
32fs::path
AbsPathJoin(
const fs::path& base,
const fs::path& path)
34 assert(base.is_absolute());
35 return path.empty() ? base : fs::path(base / path);
47 fd = open(file.c_str(), O_RDWR);
67 lock.l_type = F_WRLCK;
68 lock.l_whence = SEEK_SET;
71 if (fcntl(
fd, F_SETLK, &lock) == -1) {
81 return Win32ErrorString(GetLastError());
86 hFile = CreateFileW(file.wstring().c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
87 nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
nullptr);
88 if (hFile == INVALID_HANDLE_VALUE) {
95 if (hFile != INVALID_HANDLE_VALUE) {
102 if (hFile == INVALID_HANDLE_VALUE) {
105 _OVERLAPPED overlapped = {};
106 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.