diff options
Diffstat (limited to 'zencore/filesystem.cpp')
| -rw-r--r-- | zencore/filesystem.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 1cc5ff339..42f0c0956 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -821,10 +821,12 @@ TEST_CASE("filesystem") { using namespace std::filesystem; + // GetExePath path BinPath = GetRunningExecutablePath(); CHECK(BinPath.stem() == "zencore-test"); CHECK(is_regular_file(BinPath)); + // PathFromHandle void* Handle; #if ZEN_PLATFORM_WINDOWS Handle = CreateFileW(BinPath.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, @@ -844,6 +846,27 @@ TEST_CASE("filesystem") #else close(int(uintptr_t(Handle))); #endif + + // Traversal + struct : public FileSystemTraversal::TreeVisitor + { + virtual void VisitFile(const std::filesystem::path& Parent, const path_view& File, uint64_t FileSize) override + { + bFoundExpected |= std::filesystem::equivalent(Parent / File, Expected); + } + + virtual bool VisitDirectory(const std::filesystem::path& Parent, const path_view& DirectoryName) override + { + return true; + } + + bool bFoundExpected = false; + std::filesystem::path Expected; + } Visitor; + Visitor.Expected = BinPath; + + FileSystemTraversal().TraverseFileSystem(BinPath.parent_path().parent_path(), Visitor); + CHECK(Visitor.bFoundExpected); } } // namespace zen |