diff options
Diffstat (limited to 'zencore/filesystem.cpp')
| -rw-r--r-- | zencore/filesystem.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 663a626a1..578b28277 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -589,4 +589,22 @@ FileSystemTraversal::TraverseFileSystem(const std::filesystem::path& RootDir, Tr } } +std::filesystem::path +PathFromHandle(void* NativeHandle) +{ + if (NativeHandle == nullptr || NativeHandle == INVALID_HANDLE_VALUE) + { + return std::filesystem::path(); + } + + const DWORD RequiredLengthIncludingNul = GetFinalPathNameByHandleW(NativeHandle, nullptr, 0, FILE_NAME_OPENED); + + std::wstring FullPath; + FullPath.resize(RequiredLengthIncludingNul - 1); + + const DWORD FinalLength = GetFinalPathNameByHandleW(NativeHandle, FullPath.data(), RequiredLengthIncludingNul, FILE_NAME_OPENED); + + return FullPath; +} + } // namespace zen |