aboutsummaryrefslogtreecommitdiff
path: root/zenserver/projectstore.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2022-05-20 12:42:56 +0200
committerStefan Boberg <[email protected]>2022-05-20 12:42:56 +0200
commit5b271be0169b842cdc3d576e48bf0ddc2f122852 (patch)
tree16f501d2190f19a7281ce3f30365817464e146cb /zenserver/projectstore.cpp
parentAdded ZEN_USE_CATCH2 define (diff)
parentfix mac compilation error (diff)
downloadzen-5b271be0169b842cdc3d576e48bf0ddc2f122852.tar.xz
zen-5b271be0169b842cdc3d576e48bf0ddc2f122852.zip
Merge branch 'main' into use-catch2
Diffstat (limited to 'zenserver/projectstore.cpp')
-rw-r--r--zenserver/projectstore.cpp53
1 files changed, 10 insertions, 43 deletions
diff --git a/zenserver/projectstore.cpp b/zenserver/projectstore.cpp
index 617f50660..d18ae9e1a 100644
--- a/zenserver/projectstore.cpp
+++ b/zenserver/projectstore.cpp
@@ -804,29 +804,12 @@ ProjectStore::Project::DeleteOplog(std::string_view OplogId)
void
ProjectStore::Project::DiscoverOplogs()
{
- FileSystemTraversal Traversal;
- struct Visitor : public FileSystemTraversal::TreeVisitor
- {
- virtual void VisitFile([[maybe_unused]] const std::filesystem::path& Parent,
- [[maybe_unused]] const path_view& File,
- [[maybe_unused]] uint64_t FileSize) override
- {
- }
-
- virtual bool VisitDirectory([[maybe_unused]] const std::filesystem::path& Parent, const path_view& DirectoryName) override
- {
- Dirs.push_back(PathToUtf8(DirectoryName));
- return false;
- }
-
- std::vector<std::string> Dirs;
- } Visit;
-
- Traversal.TraverseFileSystem(m_OplogStoragePath, Visit);
+ DirectoryContent DirContent;
+ GetDirectoryContent(m_OplogStoragePath, DirectoryContent::IncludeDirsFlag, DirContent);
- for (const std::string& Dir : Visit.Dirs)
+ for (const std::filesystem::path& DirPath : DirContent.Directories)
{
- OpenOplog(Dir);
+ OpenOplog(PathToUtf8(DirPath.stem()));
}
}
@@ -900,34 +883,18 @@ ProjectStore::BasePathForProject(std::string_view ProjectId)
void
ProjectStore::DiscoverProjects()
{
- FileSystemTraversal Traversal;
- struct Visitor : public FileSystemTraversal::TreeVisitor
- {
- virtual void VisitFile([[maybe_unused]] const std::filesystem::path& Parent,
- [[maybe_unused]] const path_view& File,
- [[maybe_unused]] uint64_t FileSize) override
- {
- }
-
- virtual bool VisitDirectory([[maybe_unused]] const std::filesystem::path& Parent, const path_view& DirectoryName) override
- {
- Dirs.push_back(PathToUtf8(DirectoryName));
- return false;
- }
-
- std::vector<std::string> Dirs;
- } Visit;
-
if (!std::filesystem::exists(m_ProjectBasePath))
{
return;
}
- Traversal.TraverseFileSystem(m_ProjectBasePath, Visit);
+ DirectoryContent DirContent;
+ GetDirectoryContent(m_ProjectBasePath, DirectoryContent::IncludeDirsFlag, DirContent);
- for (const auto& Dir : Visit.Dirs)
+ for (const std::filesystem::path& DirPath : DirContent.Directories)
{
- Project* Project = OpenProject(Dir);
+ std::string DirName = PathToUtf8(DirPath.stem());
+ Project* Project = OpenProject(DirName);
if (Project)
{
@@ -976,7 +943,7 @@ ProjectStore::GatherReferences(GcContext& GcCtx)
{
Stopwatch Timer;
const auto Guard =
- MakeGuard([this, &Timer] { ZEN_INFO("project store gathered all references in {}", NiceTimeSpanMs(Timer.GetElapsedTimeMs())); });
+ MakeGuard([&] { ZEN_INFO("project store gathered all references in {}", NiceTimeSpanMs(Timer.GetElapsedTimeMs())); });
DiscoverProjects();