For PR495:
authorReid Spencer <rspencer@reidspencer.com>
Thu, 7 Jul 2005 18:21:42 +0000 (18:21 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Thu, 7 Jul 2005 18:21:42 +0000 (18:21 +0000)
Change interface to Path class:
readable -> canRead
writable -> canWrite
executable -> canExecute

More (incremental) changes coming to close 495.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22345 91177308-0d34-0410-b5e6-96231b3b80d8

12 files changed:
include/llvm/System/Path.h
lib/Debugger/ProgramInfo.cpp
lib/Linker/LinkItems.cpp
lib/Linker/Linker.cpp
lib/Support/SystemUtils.cpp
lib/System/Path.cpp
lib/System/Unix/Path.inc
lib/System/Unix/Program.inc
lib/System/Win32/Path.inc
tools/llvm-nm/llvm-nm.cpp
tools/llvmc/CompilerDriver.cpp
tools/llvmc/Configuration.cpp

index dc7e324855f508a91429e3d1a04b4db0686a5c3e..04c0a2b3d2ed9399fa435e369da1e8a5cadfef8d 100644 (file)
@@ -241,6 +241,14 @@ namespace sys {
       /// @brief Determines if the path name references a directory.
       bool isDirectory() const;
 
+      /// This function determines if the path refers to a hidden file. The
+      /// notion of hidden files is defined by  the underlying system. The
+      /// system may not support hidden files in which case this function always
+      /// returns false on such systems. Hidden files have the "hidden"
+      /// attribute set on Win32. On Unix, hidden files start with a period.
+      /// @brief Determines if the path name references a hidden file.
+      bool isHidden() const;
+
       /// This function determines if the path name in this object references
       /// the root (top level directory) of the file system. The details of what
       /// is considered the "root" may vary from system to system so this method
@@ -303,7 +311,7 @@ namespace sys {
       /// @returns true if the pathname references a readable file.
       /// @brief Determines if the path is a readable file or directory
       /// in the file system.
-      bool readable() const;
+      bool canRead() const;
 
       /// This function determines if the path name references a writable file
       /// or directory in the file system. Unlike isFile and isDirectory, this
@@ -312,7 +320,7 @@ namespace sys {
       /// @returns true if the pathname references a writable file.
       /// @brief Determines if the path is a writable file or directory
       /// in the file system.
-      bool writable() const;
+      bool canWrite() const;
 
       /// This function determines if the path name references an executable
       /// file in the file system. Unlike isFile and isDirectory, this
@@ -321,7 +329,7 @@ namespace sys {
       /// @returns true if the pathname references an executable file.
       /// @brief Determines if the path is an executable file in the file
       /// system.
-      bool executable() const;
+      bool canExecute() const;
 
       /// This function returns the current contents of the path as a
       /// std::string. This allows the underlying path string to be manipulated
index a702829c1216e5f9048232e40f4005c243741b38..144cfeb2b3e0120303f8531d4a228135e7f1ae42 100644 (file)
@@ -174,7 +174,7 @@ SourceFile &SourceFileInfo::getSourceText() const {
     if (!Directory.empty())
       tmpPath.setDirectory(Directory);
     tmpPath.appendFile(BaseName);
-    if (tmpPath.readable())
+    if (tmpPath.canRead())
       SourceText = new SourceFile(tmpPath.toString(), Descriptor);
     else
       SourceText = new SourceFile(BaseName, Descriptor);
index 34677ce3654927be575355ab7918a71e3b859bff..a67733437ee3322d1b5a8733a5290e488c8ef53d 100644 (file)
@@ -118,7 +118,7 @@ bool Linker::LinkInLibraries(const std::vector<std::string> &Libraries) {
 ///
 bool Linker::LinkInFile(const sys::Path &File) {
   // Make sure we can at least read the file
-  if (!File.readable())
+  if (!File.canRead())
     return error("Cannot find linker input '" + File.toString() + "'");
 
   // A user may specify an ar archive without -l, perhaps because it
index e09c7885930a8b826a365f231e340247263d51a3..337174039383034198d2f3fab07eb07861e4b61c 100644 (file)
@@ -153,7 +153,7 @@ Linker::FindLib(const std::string &Filename)
 {
   // Determine if the pathname can be found as it stands.
   sys::Path FilePath(Filename);
-  if (FilePath.readable() &&
+  if (FilePath.canRead() &&
       (FilePath.isArchive() || FilePath.isDynamicLibrary()))
     return FilePath;
 
index 97ae156bdd41514cd09d517a174db4a4d682fdd9..77c97f3111d51907c5cabdaaf677a2f6a4ac0d24 100644 (file)
@@ -48,7 +48,7 @@ sys::Path llvm::FindExecutable(const std::string &ExeName,
   Result.elideFile();
   if (!Result.isEmpty()) {
     Result.appendFile(ExeName);
-    if (Result.executable())
+    if (Result.canExecute())
       return Result;
   }
 
index 34cbd6d69b7fef691d1ee20de0e176d7fcaf667c..d2566fd06a4ecbee21f1e337bb02d650f4bcffb3 100644 (file)
@@ -62,14 +62,14 @@ sys::IdentifyFileType(const char*magic, unsigned length) {
 
 bool
 Path::isArchive() const {
-  if (readable())
+  if (canRead())
     return hasMagicNumber("!<arch>\012");
   return false;
 }
 
 bool
 Path::isDynamicLibrary() const {
-  if (readable())
+  if (canRead())
     return hasMagicNumber("\177ELF");
   return false;
 }
index b371d00e69ba0a3ecba3794a02dd2df34bdbc9ca..f871adb2c706ffc139f83d653d1cedb225f3a2d2 100644 (file)
@@ -168,14 +168,14 @@ static void getPathList(const char*path, std::vector<sys::Path>& Paths) {
   while( delim != 0 ) {
     std::string tmp(at, size_t(delim-at));
     if (tmpPath.setDirectory(tmp))
-      if (tmpPath.readable())
+      if (tmpPath.canRead())
         Paths.push_back(tmpPath);
     at = delim + 1;
     delim = strchr(at, ':');
   }
   if (*at != 0)
     if (tmpPath.setDirectory(std::string(at)))
-      if (tmpPath.readable())
+      if (tmpPath.canRead())
         Paths.push_back(tmpPath);
 
 }
@@ -205,7 +205,7 @@ Path::GetBytecodeLibraryPaths(std::vector<sys::Path>& Paths) {
   {
     Path tmpPath;
     if (tmpPath.setDirectory(LLVM_LIBDIR))
-      if (tmpPath.readable())
+      if (tmpPath.canRead())
         Paths.push_back(tmpPath);
   }
 #endif
@@ -305,17 +305,17 @@ Path::exists() const {
 }
 
 bool
-Path::readable() const {
+Path::canRead() const {
   return 0 == access(path.c_str(), F_OK | R_OK );
 }
 
 bool
-Path::writable() const {
+Path::canWrite() const {
   return 0 == access(path.c_str(), F_OK | W_OK );
 }
 
 bool
-Path::executable() const {
+Path::canExecute() const {
   struct stat st;
   int r = stat(path.c_str(), &st);
   if (r != 0 || !S_ISREG(st.st_mode))
index de5ae7f19780c23856928cfdf6d9e43270eeb429..774bd02e88b26e642731154b648df5b52f7c9d04 100644 (file)
@@ -46,7 +46,7 @@ Program::FindProgramByName(const std::string& progName) {
     return Path();
   // FIXME: have to check for absolute filename - we cannot assume anything
   // about "." being in $PATH
-  if (temp.executable()) // already executable as is
+  if (temp.canExecute()) // already executable as is
     return temp;
 
   // At this point, the file name is valid and its not executable
@@ -66,7 +66,7 @@ Program::FindProgramByName(const std::string& progName) {
     Path FilePath;
     if (FilePath.setDirectory(std::string(PathStr,Colon))) {
       FilePath.appendFile(progName);
-      if (FilePath.executable())
+      if (FilePath.canExecute())
         return FilePath;                    // Found the executable!
     }
 
@@ -109,7 +109,7 @@ Program::ExecuteAndWait(const Path& path,
                         const Path** redirects,
                         unsigned secondsToWait
 ) {
-  if (!path.executable())
+  if (!path.canExecute())
     throw path.toString() + " is not executable"; 
 
 #ifdef HAVE_SYS_WAIT_H
index d3c85916182b767b25683e887ffba77652f8e547..b9132da7f7261e8220fcb01ea066637b575d028e 100644 (file)
@@ -139,14 +139,14 @@ static void getPathList(const char*path, std::vector<sys::Path>& Paths) {
   while( delim != 0 ) {
     std::string tmp(at, size_t(delim-at));
     if (tmpPath.setDirectory(tmp))
-      if (tmpPath.readable())
+      if (tmpPath.canRead())
         Paths.push_back(tmpPath);
     at = delim + 1;
     delim = strchr(at, ';');
   }
   if (*at != 0)
     if (tmpPath.setDirectory(std::string(at)))
-      if (tmpPath.readable())
+      if (tmpPath.canRead())
         Paths.push_back(tmpPath);
 
 }
@@ -167,7 +167,7 @@ Path::GetBytecodeLibraryPaths(std::vector<sys::Path>& Paths) {
   {
     Path tmpPath;
     if (tmpPath.setDirectory(LLVM_LIBDIR))
-      if (tmpPath.readable())
+      if (tmpPath.canRead())
         Paths.push_back(tmpPath);
   }
 #endif
@@ -237,21 +237,21 @@ Path::exists() const {
 }
 
 bool
-Path::readable() const {
+Path::canRead() const {
   // FIXME: take security attributes into account.
   DWORD attr = GetFileAttributes(path.c_str());
   return attr != INVALID_FILE_ATTRIBUTES;
 }
 
 bool
-Path::writable() const {
+Path::canWrite() const {
   // FIXME: take security attributes into account.
   DWORD attr = GetFileAttributes(path.c_str());
   return (attr != INVALID_FILE_ATTRIBUTES) && !(attr & FILE_ATTRIBUTE_READONLY);
 }
 
 bool
-Path::executable() const {
+Path::canExecute() const {
   // FIXME: take security attributes into account.
   DWORD attr = GetFileAttributes(path.c_str());
   return attr != INVALID_FILE_ATTRIBUTES;
index f6b75928d5c4276113493646400e031ccbc77437..604e30a3d537250a9f3db4ad434952f31001dd4c 100644 (file)
@@ -119,7 +119,7 @@ void DumpSymbolNamesFromModule (Module *M) {
 void DumpSymbolNamesFromFile (std::string &Filename) {
   std::string ErrorMessage;
   sys::Path aPath(Filename);
-  if (Filename != "-" && !aPath.readable()) {
+  if (Filename != "-" && !aPath.canRead()) {
     std::cerr << ToolName << ": " << Filename << ": " << strerror (errno)
               << "\n";
     return;
index 39a2989926121e14a789510cddc43bc6d362b2c5..34e4038c139035c604ca409d5f0ff18547daa87b 100644 (file)
@@ -187,7 +187,7 @@ private:
 
   void cleanup() {
     if (!isSet(KEEP_TEMPS_FLAG)) {
-      if (TempDir.isDirectory() && TempDir.writable())
+      if (TempDir.isDirectory() && TempDir.canWrite())
         TempDir.destroyDirectory(/*remove_contents=*/true);
     } else {
       std::cout << "Temporary files are in " << TempDir << "\n";
@@ -415,7 +415,7 @@ private:
       if (progpath.isEmpty())
         throw std::string("Can't find program '" +
                           action->program.toString()+"'");
-      else if (progpath.executable())
+      else if (progpath.canExecute())
         action->program = progpath;
       else
         throw std::string("Program '"+action->program.toString()+
@@ -449,32 +449,32 @@ private:
                                         bool native = false) {
     sys::Path fullpath;
     fullpath.setFile(link_item);
-    if (fullpath.readable())
+    if (fullpath.canRead())
       return fullpath;
     for (PathVector::iterator PI = LibraryPaths.begin(),
          PE = LibraryPaths.end(); PI != PE; ++PI) {
       fullpath.setDirectory(PI->toString());
       fullpath.appendFile(link_item);
-      if (fullpath.readable())
+      if (fullpath.canRead())
         return fullpath;
       if (native) {
         fullpath.appendSuffix("a");
       } else {
         fullpath.appendSuffix("bc");
-        if (fullpath.readable())
+        if (fullpath.canRead())
           return fullpath;
         fullpath.elideSuffix();
         fullpath.appendSuffix("o");
-        if (fullpath.readable())
+        if (fullpath.canRead())
           return fullpath;
         fullpath = *PI;
         fullpath.appendFile(std::string("lib") + link_item);
         fullpath.appendSuffix("a");
-        if (fullpath.readable())
+        if (fullpath.canRead())
           return fullpath;
         fullpath.elideSuffix();
         fullpath.appendSuffix("so");
-        if (fullpath.readable())
+        if (fullpath.canRead())
           return fullpath;
       }
     }
@@ -494,7 +494,7 @@ private:
     // First, see if the unadorned file name is not readable. If so,
     // we must track down the file in the lib search path.
     sys::Path fullpath;
-    if (!link_item.readable()) {
+    if (!link_item.canRead()) {
       // look for the library using the -L arguments specified
       // on the command line.
       fullpath = GetPathForLinkageItem(link_item.toString());
index e29ece2058b7a86c9bc4bfdafa0f49efa785df24..27b1b3fb3094ab9ff5bb18c553e03a38ec93d4ff 100644 (file)
@@ -549,7 +549,7 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
     if (conf) {
       confFile.setDirectory(conf);
       confFile.appendFile(ftype);
-      if (!confFile.readable())
+      if (!confFile.canRead())
         throw std::string("Configuration file for '") + ftype +
                           "' is not available.";
     } else {
@@ -559,18 +559,18 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
         confFile.appendDirectory(".llvm");
         confFile.appendDirectory("etc");
         confFile.appendFile(ftype);
-        if (!confFile.readable())
+        if (!confFile.canRead())
           confFile.clear();
       }
       if (confFile.isEmpty()) {
         // Okay, try the LLVM installation directory
         confFile = sys::Path::GetLLVMConfigDir();
         confFile.appendFile(ftype);
-        if (!confFile.readable()) {
+        if (!confFile.canRead()) {
           // Okay, try the "standard" place
           confFile = sys::Path::GetLLVMDefaultConfigDir();
           confFile.appendFile(ftype);
-          if (!confFile.readable()) {
+          if (!confFile.canRead()) {
             throw std::string("Configuration file for '") + ftype +
                               "' is not available.";
           }
@@ -580,7 +580,7 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
   } else {
     confFile = configDir;
     confFile.appendFile(ftype);
-    if (!confFile.readable())
+    if (!confFile.canRead())
       throw std::string("Configuration file for '") + ftype +
                         "' is not available.";
   }