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

Ted Kremenek kremenek at apple.com
Tue Dec 18 11:46:22 PST 2007


Author: kremenek
Date: Tue Dec 18 13:46:22 2007
New Revision: 45168

URL: http://llvm.org/viewvc/llvm-project?rev=45168&view=rev
Log:
Added "isDirectory" method to llvm::sys::Path.

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=45168&r1=45167&r2=45168&view=diff

==============================================================================
--- llvm/trunk/include/llvm/System/Path.h (original)
+++ llvm/trunk/include/llvm/System/Path.h Tue Dec 18 13:46:22 2007
@@ -321,7 +321,7 @@
       /// shared library.
       /// @brief Determine if the path reference a dynamic library.
       bool isDynamicLibrary() const;
-
+    
       /// This function determines if the path name references an existing file
       /// or directory in the file system.
       /// @returns true if the pathname references an existing file or
@@ -330,6 +330,12 @@
       /// the file system.
       bool exists() const;
 
+      /// This function determines if the path name refences an 
+      /// existing directory.
+      /// @returns true if the pathname references an existing directory.
+      /// @brief Determins if the path is a directory in the file system.
+      bool isDirectory() 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=45168&r1=45167&r2=45168&view=diff

==============================================================================
--- llvm/trunk/lib/System/Unix/Path.inc (original)
+++ llvm/trunk/lib/System/Unix/Path.inc Tue Dec 18 13:46:22 2007
@@ -289,6 +289,14 @@
 }
 
 bool
+Path::isDirectory() const {
+  struct stat buf;
+  if (0 != stat(path.c_str(), &buf))
+    return false;
+  return buf.st_mode & S_IFDIR ? true : false;
+}
+
+bool
 Path::canRead() const {
   return 0 == access(path.c_str(), F_OK | 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=45168&r1=45167&r2=45168&view=diff

==============================================================================
--- llvm/trunk/lib/System/Win32/Path.inc (original)
+++ llvm/trunk/lib/System/Win32/Path.inc Tue Dec 18 13:46:22 2007
@@ -254,6 +254,13 @@
 }
 
 bool
+Path::isDirectory() const {
+  DWORD attr = GetFileAttributes(path.c_str());
+  return (attr != INVALID_FILE_ATTRIBUTES) &&
+         (attr & FILE_ATTRIBUTE_DIRECTORY);
+}
+
+bool
 Path::canRead() const {
   // FIXME: take security attributes into account.
   DWORD attr = GetFileAttributes(path.c_str());





More information about the llvm-commits mailing list