API change Path::isSpecialFile to Path::isRegularFile, improve semantics in regards...
authorEdward O'Callaghan <eocallaghan@auroraux.org>
Wed, 25 Nov 2009 06:32:19 +0000 (06:32 +0000)
committerEdward O'Callaghan <eocallaghan@auroraux.org>
Wed, 25 Nov 2009 06:32:19 +0000 (06:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89848 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/System/Path.h
lib/System/Unix/Path.inc
lib/System/Win32/Path.inc

index 04dba1db3e25e7ff56a551c020344d7b052d6294..7edd5c082079ed2f10016f5c3e9eaad4bf740ff6 100644 (file)
@@ -380,10 +380,12 @@ namespace sys {
       /// in the file system.
       bool canWrite() const;
 
-      /// This function checks that what we're trying to work only on a regular file or directory.
-      /// Check for things like /dev/null, any block special file,
+      /// This function checks that what we're trying to work only on a regular file
+      /// or directory. Check for things like /dev/null, any block special file,
       /// or other things that aren't "regular" regular files or directories.
-      bool isSpecialFile() const;
+      /// @returns true if the file is S_ISREG.
+      /// @brief Determines if the file is a regular file
+      bool isRegularFile() const;
 
       /// This function determines if the path name references an executable
       /// file in the file system. This function checks for the existence and
index 8dd76a741285c7c2329a433dcd28801eb1d6983f..4300d6719b3393e26f7174f6babf4f5ae10ebb24 100644 (file)
@@ -454,17 +454,17 @@ Path::canWrite() const {
 }
 
 bool
-Path::isSpecialFile() const {
+Path::isRegularFile() const {
   // Get the status so we can determine if its a file or directory
   struct stat buf;
 
   if (0 != stat(path.c_str(), &buf))
-    return true;
-
-  if (S_ISDIR(buf.st_mode) || S_ISREG(buf.st_mode))
     return false;
 
-  return true;
+  if (S_ISREG(buf.st_mode))
+    return true;
+
+  return false;
 }
 
 bool
index 9adeca241034f7060abe97153f2c7d8b2c0580df..634fbc7650b3b4849a11d3498374d9cd19b4bf6e 100644 (file)
@@ -358,8 +358,10 @@ Path::canExecute() const {
 }
 
 bool
-Path::isSpecialFile() const {
-  return false;
+Path::isRegularFile() const {
+  if (isDirectory())
+    return false;
+  return true;
 }
 
 std::string