From 74ef06cb92d18079f5733083307e508efc85b9b3 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Wed, 15 Sep 2021 16:29:45 +0200 Subject: Implemented PathFromHandle() for Linux --- zencore/filesystem.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 329cc241d..981935c55 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -605,6 +605,7 @@ FileSystemTraversal::TraverseFileSystem(const std::filesystem::path& RootDir, Tr std::filesystem::path PathFromHandle(void* NativeHandle) { +#if ZEN_PLATFORM_WINDOWS if (NativeHandle == nullptr || NativeHandle == INVALID_HANDLE_VALUE) { return std::filesystem::path(); @@ -618,6 +619,18 @@ PathFromHandle(void* NativeHandle) const DWORD FinalLength = GetFinalPathNameByHandleW(NativeHandle, FullPath.data(), RequiredLengthIncludingNul, FILE_NAME_OPENED); return FullPath; +#elif ZEN_PLATFORM_LINUX + char Buffer[256]; + sprintf(Buffer, "/proc/%d/fd/%d", getpid(), int(uintptr_t(NativeHandle))); + ssize_t BytesRead = readlink(Buffer, Buffer, sizeof(Buffer) - 1); + if (BytesRead <= 0) + return std::filesystem::path(); + + Buffer[BytesRead] = '\0'; + return Buffer; +#else +# error Unimplemented platform +#endif // ZEN_PLATFORM_WINDOWS } std::filesystem::path -- cgit v1.2.3 From 13761b54f48d7d4f0f6982e3726d56345ac1f739 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Wed, 15 Sep 2021 16:32:08 +0200 Subject: Implemented GetRunningExecutablePath() for Linux --- zencore/filesystem.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 981935c55..4f3ee44b0 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -636,10 +636,23 @@ PathFromHandle(void* NativeHandle) std::filesystem::path GetRunningExecutablePath() { +#if ZEN_PLATFORM_WINDOWS TCHAR ExePath[MAX_PATH]; DWORD PathLength = GetModuleFileName(NULL, ExePath, ZEN_ARRAY_COUNT(ExePath)); return {std::wstring_view(ExePath, PathLength)}; +#elif ZEN_PLATFORM_LINUX + char Buffer[256]; + sprintf(Buffer, "/proc/%d/exe", getpid()); + ssize_t BytesRead = readlink(Buffer, Buffer, sizeof(Buffer) - 1); + if (BytesRead < 0) + return {}; + + Buffer[BytesRead] = '\0'; + return Buffer; +#else +# error Unimplemented platform +#endif // ZEN_PLATFORM_WINDOWS } } // namespace zen -- cgit v1.2.3 From 75a1cb75d080bdc56c351c359acdef19a9865608 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Wed, 15 Sep 2021 16:32:59 +0200 Subject: Added a simple filesystem test case --- zencore/filesystem.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 4f3ee44b0..14eef812f 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -15,6 +15,7 @@ #include #include +#include #include namespace zen { @@ -655,4 +656,45 @@ GetRunningExecutablePath() #endif // ZEN_PLATFORM_WINDOWS } + + +////////////////////////////////////////////////////////////////////////// +// +// Testing related code follows... +// + +void +filesystem_forcelink() +{ +} + +TEST_CASE("filesystem") +{ + using namespace std::filesystem; + + path BinPath = GetRunningExecutablePath(); + CHECK(BinPath.stem() == "zencore-test"); + CHECK(is_regular_file(BinPath)); + + void* Handle; +#if ZEN_PLATFORM_WINDOWS + Handle = CreateFileW(BinPath.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, + OPEN_EXISTING, 0, nullptr); + CHECK(Handle != INVALID_HANDLE_VALUE); +#else + int Fd = open(BinPath.c_str(), O_RDONLY); + CHECK(Fd >= 0); + Handle = (void*)uintptr_t(Fd); +#endif + + auto FromHandle = PathFromHandle((void*)uintptr_t(Handle)); + CHECK(equivalent(FromHandle, BinPath)); + +#if ZEN_PLATFORM_WINDOWS + CloseHandle(Handle); +#else + close(int(uintptr_t(Handle))); +#endif +} + } // namespace zen -- cgit v1.2.3 From d4fa48316af92568a28dc4d56344e74eca67dd5d Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Thu, 16 Sep 2021 13:50:25 +0200 Subject: Fixed up platform-specific includes --- zencore/filesystem.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 2942910ed..3e00f596a 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -7,12 +7,16 @@ #include #include #include -#include +#if ZEN_PLATFORM_WINDOWS +# include +#endif -#include -#include -#include -#include +#if ZEN_PLATFORM_WINDOWS +# include +# include +# include +# include +#endif #include #include -- cgit v1.2.3 From df3c963bedfcda2a080c13dd63fdc4f9c6bc7691 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Thu, 16 Sep 2021 16:33:28 +0200 Subject: The wchar_t variants of directory functions are now only enabled on Windows --- zencore/filesystem.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 3e00f596a..1ddde9d88 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -26,6 +26,8 @@ namespace zen { using namespace std::literals; +#if ZEN_PLATFORM_WINDOWS + static bool DeleteReparsePoint(const wchar_t* Path, DWORD dwReparseTag) { @@ -58,12 +60,6 @@ CreateDirectories(const wchar_t* Dir) return std::filesystem::create_directories(Dir); } -bool -CreateDirectories(const std::filesystem::path& Dir) -{ - return std::filesystem::create_directories(Dir); -} - // Erase all files and directories in a given directory, leaving an empty directory // behind @@ -162,6 +158,14 @@ CleanDirectory(const wchar_t* DirPath) } } +#endif // ZEN_PLATFORM_WINDOWS + +bool +CreateDirectories(const std::filesystem::path& Dir) +{ + return std::filesystem::create_directories(Dir); +} + bool DeleteDirectories(const std::filesystem::path& Dir) { -- cgit v1.2.3 From 789a34d63b8626e6b35b456ce2edd5a274f66aff Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Thu, 16 Sep 2021 16:34:45 +0200 Subject: Non-Windows implementation of Clean/DeleteDirectory() using std::fs --- zencore/filesystem.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 1ddde9d88..fb22befdf 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -169,13 +169,35 @@ CreateDirectories(const std::filesystem::path& Dir) bool DeleteDirectories(const std::filesystem::path& Dir) { +#if ZEN_PLATFORM_WINDOWS return DeleteDirectories(Dir.c_str()); +#else + std::error_code ErrorCode; + return std::filesystem::remove_all(Dir, ErrorCode); +#endif } bool CleanDirectory(const std::filesystem::path& Dir) { +#if ZEN_PLATFORM_WINDOWS return CleanDirectory(Dir.c_str()); +#else + if (std::filesystem::exists(Dir)) + { + bool Success = true; + + std::error_code ErrorCode; + for (const auto& Item : std::filesystem::directory_iterator(Dir)) + { + Success &= std::filesystem::remove_all(Item, ErrorCode); + } + + return Success; + } + + return CreateDirectories(Dir); +#endif } ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From fc4ec57f72d3a20df6d06cc8aa8e06ce13fabd1e Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Thu, 16 Sep 2021 16:39:07 +0200 Subject: Stubbed out seldom-used *File() functions with a ZEN_ERROR() for Linux --- zencore/filesystem.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index fb22befdf..4b96f057e 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -205,6 +205,7 @@ CleanDirectory(const std::filesystem::path& Dir) bool SupportsBlockRefCounting(std::filesystem::path Path) { +#if ZEN_PLATFORM_WINDOWS ATL::CHandle Handle(CreateFileW(Path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, @@ -231,11 +232,15 @@ SupportsBlockRefCounting(std::filesystem::path Path) } return true; +#else + return false; +#endif // ZEN_PLATFORM_WINDOWS } bool CloneFile(std::filesystem::path FromPath, std::filesystem::path ToPath) { +#if ZEN_PLATFORM_WINDOWS ATL::CHandle FromFile(CreateFileW(FromPath.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr)); if (FromFile == INVALID_HANDLE_VALUE) { @@ -390,11 +395,16 @@ CloneFile(std::filesystem::path FromPath, std::filesystem::path ToPath) const bool AllOk = (TRUE == SetFileInformationByHandle(TargetFile, FileDispositionInfo, &FileDisposition, sizeof FileDisposition)); return AllOk; +#else + ZEN_ERROR("CloneFile() is not implemented on this platform"); + return false; +#endif // ZEN_PLATFORM_WINDOWS } bool CopyFile(std::filesystem::path FromPath, std::filesystem::path ToPath, const CopyFileOptions& Options) { +#if ZEN_PLATFORM_WINDOWS bool Success = false; if (Options.EnableClone) @@ -426,6 +436,10 @@ CopyFile(std::filesystem::path FromPath, std::filesystem::path ToPath, const Cop } return Success; +#else + ZEN_ERROR("CopyFile() is not implemented on this platform"); + return false; +#endif // ZEN_PLATFORM_WINDOWS } void @@ -507,6 +521,7 @@ ReadFile(std::filesystem::path Path) bool ScanFile(std::filesystem::path Path, const uint64_t ChunkSize, std::function&& ProcessFunc) { +#if ZEN_PLATFORM_WINDOWS ATL::CHandle FromFile(CreateFileW(Path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr)); if (FromFile == INVALID_HANDLE_VALUE) { @@ -533,6 +548,10 @@ ScanFile(std::filesystem::path Path, const uint64_t ChunkSize, std::function Date: Thu, 16 Sep 2021 16:40:28 +0200 Subject: POSIX implementation of WriteFile() --- zencore/filesystem.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 4b96f057e..6c5c32565 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -16,7 +16,11 @@ # include # include # include +#else +# include +# include #endif + #include #include @@ -447,6 +451,7 @@ WriteFile(std::filesystem::path Path, const IoBuffer* const* Data, size_t Buffer { using namespace fmt::literals; +#if ZEN_PLATFORM_WINDOWS CAtlFile Outfile; HRESULT hRes = Outfile.Create(Path.c_str(), GENERIC_WRITE, FILE_SHARE_READ, CREATE_ALWAYS); if (hRes == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)) @@ -461,6 +466,20 @@ WriteFile(std::filesystem::path Path, const IoBuffer* const* Data, size_t Buffer zen::ThrowSystemException(hRes, "File open failed for '{}'"_format(Path).c_str()); } +#else + int Fd = open(Path.c_str(), O_WRONLY); + if (Fd < 0) + { + zen::CreateDirectories(Path.parent_path()); + Fd = open(Path.c_str(), O_WRONLY); + } + + if (Fd < 0) + { + ThrowLastError("File open failed for '{}'"_format(Path)); + } +#endif + // TODO: this should be block-enlightened for (size_t i = 0; i < BufferCount; ++i) @@ -472,17 +491,27 @@ WriteFile(std::filesystem::path Path, const IoBuffer* const* Data, size_t Buffer { const uint64_t ChunkSize = zen::Min(WriteSize, uint64_t(2) * 1024 * 1024 * 1024); +#if ZEN_PLATFORM_WINDOWS hRes = Outfile.Write(DataPtr, gsl::narrow_cast(WriteSize)); - if (FAILED(hRes)) { zen::ThrowSystemException(hRes, "File write failed for '{}'"_format(Path).c_str()); } +#else + if (write(Fd, DataPtr, WriteSize) != WriteSize) + { + ThrowLastError("File write failed for '{}'"_format(Path)); + } +#endif // ZEN_PLATFORM_WINDOWS WriteSize -= ChunkSize; DataPtr = reinterpret_cast(DataPtr) + ChunkSize; } } + +#if !ZEN_PLATFORM_WINDOWS + close(Fd); +#endif } void -- cgit v1.2.3 From 7e6050246217e381408b7d649d5d0edae344d8e1 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Thu, 16 Sep 2021 16:41:12 +0200 Subject: POSIX implementation of ReadFile() --- zencore/filesystem.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 6c5c32565..a042fb7a1 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -525,6 +525,10 @@ WriteFile(std::filesystem::path Path, IoBuffer Data) FileContents ReadFile(std::filesystem::path Path) { + uint64_t FileSizeBytes; + void* Handle; + +#if ZEN_PLATFORM_WINDOWS ATL::CHandle FromFile(CreateFileW(Path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr)); if (FromFile == INVALID_HANDLE_VALUE) { @@ -538,12 +542,25 @@ ReadFile(std::filesystem::path Path) return FileContents{.ErrorCode = std::error_code(::GetLastError(), std::system_category())}; } - const uint64_t FileSizeBytes = FileSize.EndOfFile.QuadPart; + FileSizeBytes = FileSize.EndOfFile.QuadPart; + Handle = FromFile.Detach(); +#else + int Fd = open(Path.c_str(), O_RDONLY); + if (Fd < 0) + { + return FileContents{.ErrorCode = std::error_code(zen::GetLastError(), std::system_category())}; + } - FileContents Contents; + static_assert(sizeof(decltype(stat::st_size)) == sizeof(uint64_t), "fstat() doesn't support large files"); + struct stat Stat; + fstat(Fd, &Stat); - Contents.Data.emplace_back(IoBuffer(IoBuffer::File, FromFile.Detach(), 0, FileSizeBytes)); + FileSizeBytes = Stat.st_size; + Handle = (void*)uintptr_t(Fd); +#endif + FileContents Contents; + Contents.Data.emplace_back(IoBuffer(IoBuffer::File, Handle, 0, FileSizeBytes)); return Contents; } -- cgit v1.2.3 From 6ea9e1934ef3ded5be7c873dcaa89199363ea548 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Thu, 16 Sep 2021 16:41:35 +0200 Subject: Missing include for getpid() --- zencore/filesystem.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index a042fb7a1..741e3ee19 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -19,6 +19,7 @@ #else # include # include +# include #endif #include -- cgit v1.2.3 From d39fdc301d85ea39abe331e59a49273626a98a6c Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Thu, 16 Sep 2021 16:42:08 +0200 Subject: Implemented FileSysTraversal for Linux using open/read/closedir() --- zencore/filesystem.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 741e3ee19..a03623196 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -17,6 +17,7 @@ # include # include #else +# include # include # include # include @@ -610,6 +611,7 @@ ToUtf8(const std::filesystem::path& Path) void FileSystemTraversal::TraverseFileSystem(const std::filesystem::path& RootDir, TreeVisitor& Visitor) { +#if ZEN_PLATFORM_WINDOWS uint64_t FileInfoBuffer[8 * 1024]; FILE_INFO_BY_HANDLE_CLASS FibClass = FileIdBothDirectoryRestartInfo; @@ -697,8 +699,53 @@ FileSystemTraversal::TraverseFileSystem(const std::filesystem::path& RootDir, Tr EntryOffset += NextOffset; } } +#else + using namespace fmt::literals; + + /* Could also implement this using Linux's getdents() syscall */ + + DIR* Dir = opendir(RootDir.c_str()); + if (Dir == nullptr) + { + ThrowLastError("Failed to open directory for traversal: {}"_format(RootDir.c_str())); + } + + for (struct dirent* Entry; Entry = readdir(Dir);) + { + const char* FileName = Entry->d_name; + + struct stat Stat; + std::filesystem::path FullPath = RootDir / FileName; + stat(FullPath.c_str(), &Stat); + + if (S_ISDIR(Stat.st_mode)) + { + if (strcmp(FileName, ".") == 0 || strcmp(FileName, "..") == 0) + { + /* nop */ + } + else if (Visitor.VisitDirectory(RootDir, FileName)) + { + TraverseFileSystem(FullPath, Visitor); + } + } + else if (S_ISREG(Stat.st_mode)) + { + Visitor.VisitFile(RootDir, FileName, Stat.st_size); + } + else + { + ZEN_WARN("encountered non-regular file during file system traversal ({}): {} found in {}", + Stat.st_mode, FileName, RootDir.c_str()); + } + } + + closedir(Dir); +#endif // ZEN_PLATFORM_WINDOWS } + + std::filesystem::path PathFromHandle(void* NativeHandle) { -- cgit v1.2.3 From 434a5ea8c5ac40530e45b2e8848ab6cb742979be Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Thu, 16 Sep 2021 16:42:52 +0200 Subject: ToUtf8() for non-wchar_t platforms --- zencore/filesystem.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index a03623196..1cc5ff339 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -605,7 +605,11 @@ ScanFile(std::filesystem::path Path, const uint64_t ChunkSize, std::function Date: Thu, 16 Sep 2021 16:43:27 +0200 Subject: Simple FileSystemTraversal test case --- zencore/filesystem.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'zencore/filesystem.cpp') 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 -- cgit v1.2.3 From b3bab9685b82269d3a2abcd7972709f9a9e8aa55 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Thu, 16 Sep 2021 16:44:00 +0200 Subject: There is no need to go to a wstring here as fs::path is already one --- zencore/filesystem.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 42f0c0956..ece530474 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -621,10 +621,8 @@ FileSystemTraversal::TraverseFileSystem(const std::filesystem::path& RootDir, Tr FILE_INFO_BY_HANDLE_CLASS FibClass = FileIdBothDirectoryRestartInfo; bool Continue = true; - std::wstring RootDirPath = RootDir.native(); - CAtlFile RootDirHandle; - HRESULT hRes = RootDirHandle.Create(RootDirPath.c_str(), + HRESULT hRes = RootDirHandle.Create(RootDir.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING, -- cgit v1.2.3 From fb7eaff9992798ce6706b1fed13569277c60d1bb Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Thu, 16 Sep 2021 16:45:16 +0200 Subject: Make sure RootDir argument to formatted-print is a UTF8 string --- zencore/filesystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index ece530474..c58813152 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -682,7 +682,7 @@ FileSystemTraversal::TraverseFileSystem(const std::filesystem::path& RootDir, Tr } else if (DirInfo->FileAttributes & FILE_ATTRIBUTE_DEVICE) { - ZEN_WARN("encountered device node during file system traversal: {} found in {}", WideToUtf8(FileName), RootDir); + ZEN_WARN("encountered device node during file system traversal: {} found in {}", WideToUtf8(FileName), WideToUtf8(RootDir.c_str())); } else { -- cgit v1.2.3 From c5fd2c4eff0036e7194b7260023a95f17a79d936 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Thu, 16 Sep 2021 16:45:43 +0200 Subject: Deleted unused FilePath variable --- zencore/filesystem.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index c58813152..dca1bf6ff 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -686,8 +686,6 @@ FileSystemTraversal::TraverseFileSystem(const std::filesystem::path& RootDir, Tr } else { - std::filesystem::path FullPath = RootDir / FileName; - Visitor.VisitFile(RootDir, FileName, DirInfo->EndOfFile.QuadPart); } -- cgit v1.2.3 From 30472afa4492ec07aab2ddd830f2098eaad843e1 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Thu, 16 Sep 2021 16:48:27 +0200 Subject: Fixed "unreferenced formal parameter" warning --- zencore/filesystem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'zencore/filesystem.cpp') diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index dca1bf6ff..afbddcdbd 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -846,12 +846,12 @@ TEST_CASE("filesystem") // Traversal struct : public FileSystemTraversal::TreeVisitor { - virtual void VisitFile(const std::filesystem::path& Parent, const path_view& File, uint64_t FileSize) override + virtual void VisitFile(const std::filesystem::path& Parent, const path_view& File, uint64_t) override { bFoundExpected |= std::filesystem::equivalent(Parent / File, Expected); } - virtual bool VisitDirectory(const std::filesystem::path& Parent, const path_view& DirectoryName) override + virtual bool VisitDirectory(const std::filesystem::path&, const path_view&) override { return true; } -- cgit v1.2.3