aboutsummaryrefslogtreecommitdiff
path: root/zenstore/filecas.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-04-19 10:43:28 +0200
committerStefan Boberg <[email protected]>2023-04-19 10:52:48 +0200
commit9fb9d6ce5aaedd4ecf4f7bdc9c33a94b1e6597b2 (patch)
tree924c8ede64e087a5bdfeeb87862bc08e325f4ddc /zenstore/filecas.cpp
parentadded missing #pragma once (diff)
downloadzen-9fb9d6ce5aaedd4ecf4f7bdc9c33a94b1e6597b2.tar.xz
zen-9fb9d6ce5aaedd4ecf4f7bdc9c33a94b1e6597b2.zip
tweaks for enabling unity builds
mostly changes to make sure anonymous namespaces don't clash and a change to avoid windows headers from leaking into other compilation units unity builds are not yet enabled by default, but can be enabled by uncommenting this line in the root `xmake.lua` ``` --add_rules("c++.unity_build") ```
Diffstat (limited to 'zenstore/filecas.cpp')
-rw-r--r--zenstore/filecas.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/zenstore/filecas.cpp b/zenstore/filecas.cpp
index b4729d558..986cc9ae6 100644
--- a/zenstore/filecas.cpp
+++ b/zenstore/filecas.cpp
@@ -39,7 +39,7 @@ ZEN_THIRD_PARTY_INCLUDES_END
namespace zen {
-namespace {
+namespace filecas::impl {
const char* IndexExtension = ".uidx";
const char* LogExtension = ".ulog";
@@ -77,7 +77,7 @@ namespace {
#pragma pack(pop)
-} // namespace
+} // namespace filecas::impl
FileCasStrategy::ShardingHelper::ShardingHelper(const std::filesystem::path& RootPath, const IoHash& ChunkHash)
{
@@ -125,6 +125,8 @@ FileCasStrategy::~FileCasStrategy()
void
FileCasStrategy::Initialize(const std::filesystem::path& RootDirectory, bool IsNewStore)
{
+ using namespace filecas::impl;
+
m_IsInitialized = true;
m_RootDirectory = RootDirectory;
@@ -1013,6 +1015,8 @@ FileCasStrategy::ValidateEntry(const FileCasIndexEntry& Entry, std::string& OutR
void
FileCasStrategy::MakeIndexSnapshot()
{
+ using namespace filecas::impl;
+
uint64_t LogCount = m_CasLog.GetLogCount();
if (m_LogFlushPosition == LogCount)
{
@@ -1062,12 +1066,12 @@ FileCasStrategy::MakeIndexSnapshot()
BasicFile ObjectIndexFile;
ObjectIndexFile.Open(IndexPath, BasicFile::Mode::kTruncate);
- FileCasIndexHeader Header = {.EntryCount = Entries.size(), .LogPosition = LogCount};
+ filecas::impl::FileCasIndexHeader Header = {.EntryCount = Entries.size(), .LogPosition = LogCount};
- Header.Checksum = FileCasIndexHeader::ComputeChecksum(Header);
+ Header.Checksum = filecas::impl::FileCasIndexHeader::ComputeChecksum(Header);
- ObjectIndexFile.Write(&Header, sizeof(FileCasIndexHeader), 0);
- ObjectIndexFile.Write(Entries.data(), Entries.size() * sizeof(FileCasIndexEntry), sizeof(FileCasIndexHeader));
+ ObjectIndexFile.Write(&Header, sizeof(filecas::impl::FileCasIndexHeader), 0);
+ ObjectIndexFile.Write(Entries.data(), Entries.size() * sizeof(FileCasIndexEntry), sizeof(filecas::impl::FileCasIndexHeader));
ObjectIndexFile.Flush();
ObjectIndexFile.Close();
EntryCount = Entries.size();
@@ -1093,6 +1097,8 @@ FileCasStrategy::MakeIndexSnapshot()
uint64_t
FileCasStrategy::ReadIndexFile()
{
+ using namespace filecas::impl;
+
std::vector<FileCasIndexEntry> Entries;
std::filesystem::path IndexPath = GetIndexPath(m_RootDirectory);
if (std::filesystem::is_regular_file(IndexPath))
@@ -1179,6 +1185,8 @@ FileCasStrategy::ReadIndexFile()
uint64_t
FileCasStrategy::ReadLog(uint64_t SkipEntryCount)
{
+ using namespace filecas::impl;
+
std::filesystem::path LogPath = GetLogPath(m_RootDirectory);
if (std::filesystem::is_regular_file(LogPath))
{
@@ -1230,6 +1238,8 @@ FileCasStrategy::ReadLog(uint64_t SkipEntryCount)
std::vector<FileCasStrategy::FileCasIndexEntry>
FileCasStrategy::ScanFolderForCasFiles(const std::filesystem::path& RootDir)
{
+ using namespace filecas::impl;
+
std::vector<FileCasIndexEntry> Entries;
struct Visitor : public FileSystemTraversal::TreeVisitor
{