aboutsummaryrefslogtreecommitdiff
path: root/zenserver/projectstore.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-05-06 11:53:11 +0200
committerDan Engelbrecht <[email protected]>2022-05-06 11:53:11 +0200
commite4b96fade542151fca17b5ac61e3eaad263ce92c (patch)
tree7466cbb6bed79fb4a211a3533210245c21f211eb /zenserver/projectstore.cpp
parentreverted unnecessary changes (diff)
downloadzen-e4b96fade542151fca17b5ac61e3eaad263ce92c.tar.xz
zen-e4b96fade542151fca17b5ac61e3eaad263ce92c.zip
Added GetDirectoryContent utility
Diffstat (limited to 'zenserver/projectstore.cpp')
-rw-r--r--zenserver/projectstore.cpp51
1 files changed, 9 insertions, 42 deletions
diff --git a/zenserver/projectstore.cpp b/zenserver/projectstore.cpp
index aceb2df00..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)
{