diff options
author | Edward O'Callaghan <eocallaghan@auroraux.org> | 2009-11-24 15:19:10 +0000 |
---|---|---|
committer | Edward O'Callaghan <eocallaghan@auroraux.org> | 2009-11-24 15:19:10 +0000 |
commit | d41e944501a57aadf05b160ac30f383ed0432060 (patch) | |
tree | f6ca9493e28d8c99f3b156e31f1df222f9ca4260 /lib | |
parent | de8d3b73c85aa1a68959d296088fe022c839003f (diff) | |
download | external_llvm-d41e944501a57aadf05b160ac30f383ed0432060.zip external_llvm-d41e944501a57aadf05b160ac30f383ed0432060.tar.gz external_llvm-d41e944501a57aadf05b160ac30f383ed0432060.tar.bz2 |
Provide Path::isSpecialFile interface for PR5568.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89765 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/System/Unix/Path.inc | 22 | ||||
-rw-r--r-- | lib/System/Win32/Path.inc | 5 |
2 files changed, 25 insertions, 2 deletions
diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc index 89285b4..d134aaa 100644 --- a/lib/System/Unix/Path.inc +++ b/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"); diff --git a/lib/System/Win32/Path.inc b/lib/System/Win32/Path.inc index 573369e..9adeca2 100644 --- a/lib/System/Win32/Path.inc +++ b/lib/System/Win32/Path.inc @@ -357,6 +357,11 @@ Path::canExecute() const { return attr != INVALID_FILE_ATTRIBUTES; } +bool +Path::isSpecialFile() const { + return false; +} + std::string Path::getLast() const { // Find the last slash |