diff options
| author | Matt Peters <[email protected]> | 2022-01-10 10:57:59 -0700 |
|---|---|---|
| committer | Matt Peters <[email protected]> | 2022-01-10 10:57:59 -0700 |
| commit | 4a12683b27adb31bde9eb8f7df3b9e9cc8ec680a (patch) | |
| tree | c8b2939d400dd4bccae73d2782b15c65d30db19d /zenstore/basicfile.cpp | |
| parent | Add WaitForQuiescence RPC (diff) | |
| parent | Two missing override keywords (diff) | |
| download | zen-wait_for_quiescence.tar.xz zen-wait_for_quiescence.zip | |
Merge branch 'main' into wait_for_quiescencewait_for_quiescence
Diffstat (limited to 'zenstore/basicfile.cpp')
| -rw-r--r-- | zenstore/basicfile.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/zenstore/basicfile.cpp b/zenstore/basicfile.cpp index 80d9a2204..dcd9a8575 100644 --- a/zenstore/basicfile.cpp +++ b/zenstore/basicfile.cpp @@ -15,6 +15,7 @@ # include <fcntl.h> # include <sys/file.h> # include <sys/stat.h> +# include <unistd.h> #endif #include <fmt/format.h> @@ -22,8 +23,6 @@ namespace zen { -using namespace fmt::literals; - BasicFile::~BasicFile() { Close(); @@ -37,7 +36,7 @@ BasicFile::Open(std::filesystem::path FileName, bool IsCreate) if (Ec) { - throw std::system_error(Ec, "failed to open file '{}'"_format(FileName)); + throw std::system_error(Ec, fmt::format("failed to open file '{}'", FileName)); } } @@ -132,7 +131,7 @@ BasicFile::Read(void* Data, uint64_t BytesToRead, uint64_t FileOffset) if (!Success) { - ThrowLastError("Failed to read from file '{}'"_format(zen::PathFromHandle(m_FileHandle))); + ThrowLastError(fmt::format("Failed to read from file '{}'", zen::PathFromHandle(m_FileHandle))); } BytesToRead -= NumberOfBytesToRead; @@ -238,7 +237,7 @@ BasicFile::Write(const void* Data, uint64_t Size, uint64_t Offset) if (Ec) { - throw std::system_error(Ec, "Failed to write to file '{}'"_format(zen::PathFromHandle(m_FileHandle))); + throw std::system_error(Ec, fmt::format("Failed to write to file '{}'", zen::PathFromHandle(m_FileHandle))); } } @@ -334,11 +333,9 @@ LockFile::LockFile() LockFile::~LockFile() { -#if ZEN_PLATFORM_LINUX +#if ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC int Fd = int(intptr_t(m_FileHandle)); flock(Fd, LOCK_UN | LOCK_NB); -#elif ZEN_PLATFORM_MAC -# error check flock() support #endif } @@ -368,7 +365,7 @@ LockFile::Create(std::filesystem::path FileName, CbObject Payload, std::error_co return; } -#elif ZEN_PLATFORM_LINUX +#elif ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC int Fd = open(FileName.c_str(), O_RDWR | O_CREAT, 0666); if (Fd < 0) { @@ -385,8 +382,6 @@ LockFile::Create(std::filesystem::path FileName, CbObject Payload, std::error_co } void* FileHandle = (void*)uintptr_t(Fd); -#else -# error check flock() support #endif m_FileHandle = FileHandle; |