summaryrefslogtreecommitdiffstats
path: root/llvm/lib/System/Unix/Path.inc
diff options
context:
space:
mode:
authorEdward O'Callaghan <eocallaghan@auroraux.org>2009-11-24 15:19:10 +0000
committerEdward O'Callaghan <eocallaghan@auroraux.org>2009-11-24 15:19:10 +0000
commitdddf134a3cea47a2ab2ad7ede189d1fe29be7211 (patch)
treed35aa4a43f7dc1c9041f5d1aafb64230b3878f00 /llvm/lib/System/Unix/Path.inc
parentfdfca4aaef1b43594586ce555c169a01b76b85ce (diff)
downloadbcm5719-llvm-dddf134a3cea47a2ab2ad7ede189d1fe29be7211.tar.gz
bcm5719-llvm-dddf134a3cea47a2ab2ad7ede189d1fe29be7211.zip
Provide Path::isSpecialFile interface for PR5568.
llvm-svn: 89765
Diffstat (limited to 'llvm/lib/System/Unix/Path.inc')
-rw-r--r--llvm/lib/System/Unix/Path.inc22
1 files changed, 20 insertions, 2 deletions
diff --git a/llvm/lib/System/Unix/Path.inc b/llvm/lib/System/Unix/Path.inc
index 89285b48132..d134aaa79b3 100644
--- a/llvm/lib/System/Unix/Path.inc
+++ b/llvm/lib/System/Unix/Path.inc
@@ -335,7 +335,7 @@ getprogpath(char ret[PATH_MAX], const char *bin)
free(pv);
return (NULL);
}
-#endif
+#endif // __FreeBSD__
/// GetMainExecutable - Return the path to the main executable, given the
/// value of argv[0] from program startup.
@@ -454,6 +454,24 @@ Path::canWrite() const {
}
bool
+Path::isSpecialFile() const {
+ // Get the status so we can determine if its a file or directory
+ struct stat buf;
+ std::string *ErrStr;
+
+ if (0 != stat(path.c_str(), &buf)) {
+ MakeErrMsg(ErrStr, path + ": can't get status of file");
+ return true;
+ }
+
+ if (S_ISDIR(buf.st_mode) || S_ISREG(buf.st_mode)) {
+ return false;
+ }
+
+ return true;
+}
+
+bool
Path::canExecute() const {
if (0 != access(path.c_str(), R_OK | X_OK ))
return false;
@@ -723,7 +741,7 @@ Path::createTemporaryFileOnDisk(bool reuse_current, std::string* ErrMsg) {
bool
Path::eraseFromDisk(bool remove_contents, std::string *ErrStr) const {
- // Get the status so we can determin if its a file or directory
+ // Get the status so we can determine if its a file or directory
struct stat buf;
if (0 != stat(path.c_str(), &buf)) {
MakeErrMsg(ErrStr, path + ": can't get status of file");
OpenPOWER on IntegriCloud