aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/llvm/System/Path.h6
-rw-r--r--lib/System/Unix/Path.inc9
-rw-r--r--lib/System/Win32/Path.inc5
3 files changed, 20 insertions, 0 deletions
diff --git a/include/llvm/System/Path.h b/include/llvm/System/Path.h
index 2049528..cfeacd2 100644
--- a/include/llvm/System/Path.h
+++ b/include/llvm/System/Path.h
@@ -373,6 +373,12 @@ namespace sys {
/// @brief Determins if the path is a directory in the file system.
bool isDirectory() const;
+ /// This function determines if the path name refences an
+ /// existing symbolic link.
+ /// @returns true if the pathname references an existing symlink.
+ /// @brief Determins if the path is a symlink in the file system.
+ bool isSymLink() const;
+
/// This function determines if the path name references a readable file
/// or directory in the file system. This function checks for
/// the existence and readability (by the current program) of the file
diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc
index d5b7542..5ee3adc 100644
--- a/lib/System/Unix/Path.inc
+++ b/lib/System/Unix/Path.inc
@@ -434,6 +434,15 @@ Path::isDirectory() const {
}
bool
+Path::isSymLink() const {
+ struct stat buf;
+ if (0 != lstat(path.c_str(), &buf))
+ return false;
+ return S_ISLNK(buf.st_mode);
+}
+
+
+bool
Path::canRead() const {
return 0 == access(path.c_str(), R_OK);
}
diff --git a/lib/System/Win32/Path.inc b/lib/System/Win32/Path.inc
index 2ead801..4db7696 100644
--- a/lib/System/Win32/Path.inc
+++ b/lib/System/Win32/Path.inc
@@ -351,6 +351,11 @@ Path::isDirectory() const {
}
bool
+Path::isSymLink() const {
+ return false;
+}
+
+bool
Path::canRead() const {
// FIXME: take security attributes into account.
DWORD attr = GetFileAttributes(path.c_str());