summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/common/FileSpec.cpp
diff options
context:
space:
mode:
authorOleksiy Vyalov <ovyalov@google.com>2015-07-21 01:28:22 +0000
committerOleksiy Vyalov <ovyalov@google.com>2015-07-21 01:28:22 +0000
commit8a578bf5d74d77228d48f2e3d8bdfb10e9dd9653 (patch)
tree5622ed5d5ecb53ff457bf6b7c1a442157aa4ed7d /lldb/source/Host/common/FileSpec.cpp
parentd185d21a53da9f78e124c9587e8913eb4c8c56e8 (diff)
downloadbcm5719-llvm-8a578bf5d74d77228d48f2e3d8bdfb10e9dd9653.tar.gz
bcm5719-llvm-8a578bf5d74d77228d48f2e3d8bdfb10e9dd9653.zip
Fix FileSpec::IsSymlink implementation.
http://reviews.llvm.org/D11356 llvm-svn: 242753
Diffstat (limited to 'lldb/source/Host/common/FileSpec.cpp')
-rw-r--r--lldb/source/Host/common/FileSpec.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/lldb/source/Host/common/FileSpec.cpp b/lldb/source/Host/common/FileSpec.cpp
index ceb094b9ede..a917a89d507 100644
--- a/lldb/source/Host/common/FileSpec.cpp
+++ b/lldb/source/Host/common/FileSpec.cpp
@@ -789,6 +789,28 @@ FileSpec::GetFileType () const
return eFileTypeInvalid;
}
+bool
+FileSpec::IsSymbolicLink () const
+{
+ char resolved_path[PATH_MAX];
+ if (!GetPath (resolved_path, sizeof (resolved_path)))
+ return false;
+
+#ifdef _WIN32
+ auto attrs = ::GetFileAttributes (resolved_path);
+ if (attrs == INVALID_FILE_ATTRIBUTES)
+ return false;
+
+ return (attrs & FILE_ATTRIBUTE_REPARSE_POINT);
+#else
+ struct stat file_stats;
+ if (::lstat (resolved_path, &file_stats) != 0)
+ return false;
+
+ return (file_stats.st_mode & S_IFMT) == S_IFLNK;
+#endif
+}
+
uint32_t
FileSpec::GetPermissions () const
{
OpenPOWER on IntegriCloud