diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2005-07-07 18:21:42 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2005-07-07 18:21:42 +0000 |
commit | c7f083297cd796c2fadb534307e4ef406fd68945 (patch) | |
tree | 9b2229594545a12585fe9e49e955595c4f5c5725 /lib | |
parent | 8d4b9eddc00ad2c1c8f5bada32750c72f06c1517 (diff) |
For PR495:
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Debugger/ProgramInfo.cpp | 2 | ||||
-rw-r--r-- | lib/Linker/LinkItems.cpp | 2 | ||||
-rw-r--r-- | lib/Linker/Linker.cpp | 2 | ||||
-rw-r--r-- | lib/Support/SystemUtils.cpp | 2 | ||||
-rw-r--r-- | lib/System/Path.cpp | 4 | ||||
-rw-r--r-- | lib/System/Unix/Path.inc | 12 | ||||
-rw-r--r-- | lib/System/Unix/Program.inc | 6 | ||||
-rw-r--r-- | lib/System/Win32/Path.inc | 12 |
8 files changed, 21 insertions, 21 deletions
diff --git a/lib/Debugger/ProgramInfo.cpp b/lib/Debugger/ProgramInfo.cpp index a702829c12..144cfeb2b3 100644 --- a/lib/Debugger/ProgramInfo.cpp +++ b/lib/Debugger/ProgramInfo.cpp @@ -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); diff --git a/lib/Linker/LinkItems.cpp b/lib/Linker/LinkItems.cpp index 34677ce365..a67733437e 100644 --- a/lib/Linker/LinkItems.cpp +++ b/lib/Linker/LinkItems.cpp @@ -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 diff --git a/lib/Linker/Linker.cpp b/lib/Linker/Linker.cpp index e09c788593..3371740393 100644 --- a/lib/Linker/Linker.cpp +++ b/lib/Linker/Linker.cpp @@ -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; diff --git a/lib/Support/SystemUtils.cpp b/lib/Support/SystemUtils.cpp index 97ae156bdd..77c97f3111 100644 --- a/lib/Support/SystemUtils.cpp +++ b/lib/Support/SystemUtils.cpp @@ -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; } diff --git a/lib/System/Path.cpp b/lib/System/Path.cpp index 34cbd6d69b..d2566fd06a 100644 --- a/lib/System/Path.cpp +++ b/lib/System/Path.cpp @@ -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; } diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc index b371d00e69..f871adb2c7 100644 --- a/lib/System/Unix/Path.inc +++ b/lib/System/Unix/Path.inc @@ -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)) diff --git a/lib/System/Unix/Program.inc b/lib/System/Unix/Program.inc index de5ae7f197..774bd02e88 100644 --- a/lib/System/Unix/Program.inc +++ b/lib/System/Unix/Program.inc @@ -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 diff --git a/lib/System/Win32/Path.inc b/lib/System/Win32/Path.inc index d3c8591618..b9132da7f7 100644 --- a/lib/System/Win32/Path.inc +++ b/lib/System/Win32/Path.inc @@ -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; |