12 #include <sys/utsname.h> 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)) {
fs::path AbsPathJoin(const fs::path &base, const fs::path &path)
Helper function for joining two paths.
FILE * fopen(const fs::path &p, const char *mode)
Bridge operations to C stdio.
std::string SysErrorString(int err)
Return system error string from errno value.
static std::string GetErrorReason()
std::string utf8string() const
Return a UTF-8 representation of the path as a std::string, for compatibility with code using std::st...
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...