aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/llvm/System/Path.h14
-rw-r--r--lib/Debugger/ProgramInfo.cpp2
-rw-r--r--lib/Linker/LinkItems.cpp2
-rw-r--r--lib/Linker/Linker.cpp2
-rw-r--r--lib/Support/SystemUtils.cpp2
-rw-r--r--lib/System/Path.cpp4
-rw-r--r--lib/System/Unix/Path.inc12
-rw-r--r--lib/System/Unix/Program.inc6
-rw-r--r--lib/System/Win32/Path.inc12
-rw-r--r--tools/llvm-nm/llvm-nm.cpp2
-rw-r--r--tools/llvmc/CompilerDriver.cpp18
-rw-r--r--tools/llvmc/Configuration.cpp10
12 files changed, 47 insertions, 39 deletions
diff --git a/include/llvm/System/Path.h b/include/llvm/System/Path.h
index dc7e324..04c0a2b 100644
--- a/include/llvm/System/Path.h
+++ b/include/llvm/System/Path.h
@@ -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
diff --git a/lib/Debugger/ProgramInfo.cpp b/lib/Debugger/ProgramInfo.cpp
index a702829..144cfeb 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 34677ce..a677334 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 e09c788..3371740 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 97ae156..77c97f3 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 34cbd6d..d2566fd0 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 b371d00..f871adb 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 de5ae7f..774bd02 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 d3c8591..b9132da 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;
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp
index f6b7592..604e30a 100644
--- a/tools/llvm-nm/llvm-nm.cpp
+++ b/tools/llvm-nm/llvm-nm.cpp
@@ -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;
diff --git a/tools/llvmc/CompilerDriver.cpp b/tools/llvmc/CompilerDriver.cpp
index 39a2989..34e4038 100644
--- a/tools/llvmc/CompilerDriver.cpp
+++ b/tools/llvmc/CompilerDriver.cpp
@@ -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());
diff --git a/tools/llvmc/Configuration.cpp b/tools/llvmc/Configuration.cpp
index e29ece2..27b1b3f 100644
--- a/tools/llvmc/Configuration.cpp
+++ b/tools/llvmc/Configuration.cpp
@@ -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.";
}