aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2022-01-07 12:59:34 +0100
committerMartin Ridgers <[email protected]>2022-01-07 13:03:11 +0100
commitb56ee944101c3e46a2c58631fc768642f6a3461d (patch)
treeaab5a0bf5f28d8e42d0ba42d5e9e99c6cd1955cc
parentMissing include (diff)
downloadzen-b56ee944101c3e46a2c58631fc768642f6a3461d.tar.xz
zen-b56ee944101c3e46a2c58631fc768642f6a3461d.zip
Enabled POSIX-compatible implementations on Mac
-rw-r--r--zenstore/basicfile.cpp8
-rw-r--r--zenstore/filecas.cpp8
2 files changed, 4 insertions, 12 deletions
diff --git a/zenstore/basicfile.cpp b/zenstore/basicfile.cpp
index fcd65f67d..41d296cbb 100644
--- a/zenstore/basicfile.cpp
+++ b/zenstore/basicfile.cpp
@@ -335,11 +335,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
}
@@ -369,7 +367,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)
{
@@ -386,8 +384,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;
diff --git a/zenstore/filecas.cpp b/zenstore/filecas.cpp
index 76b921994..7e3e071fb 100644
--- a/zenstore/filecas.cpp
+++ b/zenstore/filecas.cpp
@@ -271,7 +271,7 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash)
ChunkHash);
DeletePayloadFileOnClose();
-#elif ZEN_PLATFORM_LINUX
+#elif ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC
std::filesystem::path SourcePath = PathFromHandle(FileRef.FileHandle);
std::filesystem::path DestPath = Name.ShardedPath.c_str();
int Ret = link(SourcePath.c_str(), DestPath.c_str());
@@ -311,8 +311,6 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash)
{
return CasStore::InsertResult{.New = true};
}
-#else
-# error check link/unlink for this platform
#endif // ZEN_PLATFORM_*
}
@@ -345,13 +343,11 @@ FileCasStrategy::InsertChunk(const void* const ChunkData, const size_t ChunkSize
}
PayloadFile.Close();
-#elif ZEN_PLATFORM_LINUX
+#elif ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC
if (access(Name.ShardedPath.c_str(), F_OK) == 0)
{
return CasStore::InsertResult{.New = false};
}
-#else
-# error Check access() for this platform
#endif
RwLock::ExclusiveLockScope _(LockForHash(ChunkHash));