[llvm-commits] [llvm] r118367 - in /llvm/trunk: include/llvm/System/Path.h lib/System/Unix/Path.inc lib/System/Win32/Path.inc

Rafael Espindola rafael.espindola at gmail.com
Sat Nov 6 21:36:50 PDT 2010


Author: rafael
Date: Sat Nov  6 23:36:50 2010
New Revision: 118367

URL: http://llvm.org/viewvc/llvm-project?rev=118367&view=rev
Log:
Add method for checking if a path is a symbolic link.

Modified:
    llvm/trunk/include/llvm/System/Path.h
    llvm/trunk/lib/System/Unix/Path.inc
    llvm/trunk/lib/System/Win32/Path.inc

Modified: llvm/trunk/include/llvm/System/Path.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Path.h?rev=118367&r1=118366&r2=118367&view=diff
==============================================================================
--- llvm/trunk/include/llvm/System/Path.h (original)
+++ llvm/trunk/include/llvm/System/Path.h Sat Nov  6 23:36:50 2010
@@ -373,6 +373,12 @@
       /// @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

Modified: llvm/trunk/lib/System/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Path.inc?rev=118367&r1=118366&r2=118367&view=diff
==============================================================================
--- llvm/trunk/lib/System/Unix/Path.inc (original)
+++ llvm/trunk/lib/System/Unix/Path.inc Sat Nov  6 23:36:50 2010
@@ -434,6 +434,15 @@
 }
 
 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);
 }

Modified: llvm/trunk/lib/System/Win32/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Path.inc?rev=118367&r1=118366&r2=118367&view=diff
==============================================================================
--- llvm/trunk/lib/System/Win32/Path.inc (original)
+++ llvm/trunk/lib/System/Win32/Path.inc Sat Nov  6 23:36:50 2010
@@ -351,6 +351,11 @@
 }
 
 bool
+Path::isSymLink() const {
+  return false;
+}
+
+bool
 Path::canRead() const {
   // FIXME: take security attributes into account.
   DWORD attr = GetFileAttributes(path.c_str());





More information about the llvm-commits mailing list