aboutsummaryrefslogtreecommitdiff
path: root/zenstore/basicfile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zenstore/basicfile.cpp')
-rw-r--r--zenstore/basicfile.cpp17
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;