diff options
Diffstat (limited to 'zencore/filesystem.cpp')
| -rw-r--r-- | zencore/filesystem.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 95b92277b..2507037ea 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -932,23 +932,28 @@ PathFromHandle(void* NativeHandle) ZEN_UNUSED(FinalLength); return FullPath; -#elif ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC -# if ZEN_PLATFORM_LINUX - const char* SelfFdPathFormat = "/proc/self/fd/%d"; -# else - const char* SelfFdPathFormat = "dev/fd/%d"; -# endif - +#elif ZEN_PLATFORM_LINUX char Link[PATH_MAX]; char Path[64]; - sprintf(Path, SelfFdPathFormat, int(uintptr_t(NativeHandle))); + sprintf(Path, "/proc/self/fd/%d", int(uintptr_t(NativeHandle))); ssize_t BytesRead = readlink(Path, Link, sizeof(Link) - 1); if (BytesRead <= 0) + { return std::filesystem::path(); + } Link[BytesRead] = '\0'; return Link; +#elif ZEN_PLATFORM_MAC + int Fd = int(uintptr_t(NativeHandle)); + char Path[MAXPATHLEN]; + if (fcntl(Fd, F_GETPATH, Path) < 0) + { + return std::filesystem::path(); + } + + return Path; #endif // ZEN_PLATFORM_WINDOWS } |