File::GetFileSpec() support for linux patch from Stephen Wilson.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@125181 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Host/common/File.cpp b/source/Host/common/File.cpp
index e8ba529..e4b7f05 100644
--- a/source/Host/common/File.cpp
+++ b/source/Host/common/File.cpp
@@ -269,8 +269,24 @@
{
error.SetErrorString("invalid file handle");
}
+#elif defined(__linux__)
+ char proc[64];
+ char path[PATH_MAX];
+ if (::snprintf(proc, sizeof(proc), "/proc/self/fd/%d", GetDescriptor()) < 0)
+ error.SetErrorString ("Cannot resolve file descriptor\n");
+ else
+ {
+ ssize_t len;
+ if ((len = ::readlink(proc, path, sizeof(path) - 1)) == -1)
+ error.SetErrorToErrno();
+ else
+ {
+ path[len] = '\0';
+ file_spec.SetFile (path, false);
+ }
+ }
#else
- error.SetErrorString ("fcntl (fd, F_GETPATH, ...) is not supported on this platform");
+ error.SetErrorString ("File::GetFileSpec is not supported on this platform");
#endif
if (error.Fail())