forked from OSchip/llvm-project
File::GetFileSpec() support for linux patch from Stephen Wilson.
llvm-svn: 125181
This commit is contained in:
parent
292e78c3cd
commit
94d086262a
|
@ -11,6 +11,8 @@
|
|||
#define liblldb_File_h_
|
||||
#if defined(__cplusplus)
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lldb/lldb-private.h"
|
||||
|
||||
namespace lldb_private {
|
||||
|
|
|
@ -85,7 +85,7 @@ typedef enum ByteOrder
|
|||
eByteOrderInvalid = 0,
|
||||
eByteOrderBig = 1,
|
||||
eByteOrderPDP = 2,
|
||||
eByteOrderLittle = 4,
|
||||
eByteOrderLittle = 4
|
||||
} ByteOrder;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
@ -269,8 +269,24 @@ File::GetFileSpec (FileSpec &file_spec) const
|
|||
{
|
||||
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())
|
||||
|
|
Loading…
Reference in New Issue