aboutsummaryrefslogtreecommitdiff
path: root/zencore/filesystem.cpp
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2021-09-16 16:43:27 +0200
committerMartin Ridgers <[email protected]>2021-09-16 16:43:27 +0200
commit2ce672a53174e686a21c1bdc9aebd3112e79592d (patch)
treed2c3af247201f48f4942acb121c68291a64fcf35 /zencore/filesystem.cpp
parentToUtf8() for non-wchar_t platforms (diff)
downloadzen-2ce672a53174e686a21c1bdc9aebd3112e79592d.tar.xz
zen-2ce672a53174e686a21c1bdc9aebd3112e79592d.zip
Simple FileSystemTraversal test case
Diffstat (limited to 'zencore/filesystem.cpp')
-rw-r--r--zencore/filesystem.cpp23
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