diff options
author | Ted Kremenek <kremenek@apple.com> | 2007-12-18 19:46:22 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2007-12-18 19:46:22 +0000 |
commit | 74db04261b44e2a107eccf8554cb9bab1e05b5a4 (patch) | |
tree | 8f87189a523e65bf72fc9ae63ccd87ee0bf273c1 /llvm/lib | |
parent | 483a969eceb24b62f83f178f294432593d40069e (diff) | |
download | bcm5719-llvm-74db04261b44e2a107eccf8554cb9bab1e05b5a4.tar.gz bcm5719-llvm-74db04261b44e2a107eccf8554cb9bab1e05b5a4.zip |
Added "isDirectory" method to llvm::sys::Path.
llvm-svn: 45168
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/System/Unix/Path.inc | 8 | ||||
-rw-r--r-- | llvm/lib/System/Win32/Path.inc | 7 |
2 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/System/Unix/Path.inc b/llvm/lib/System/Unix/Path.inc index e4916baf280..9e90dda04e0 100644 --- a/llvm/lib/System/Unix/Path.inc +++ b/llvm/lib/System/Unix/Path.inc @@ -289,6 +289,14 @@ Path::exists() const { } bool +Path::isDirectory() const { + struct stat buf; + if (0 != stat(path.c_str(), &buf)) + return false; + return buf.st_mode & S_IFDIR ? true : false; +} + +bool Path::canRead() const { return 0 == access(path.c_str(), F_OK | R_OK ); } diff --git a/llvm/lib/System/Win32/Path.inc b/llvm/lib/System/Win32/Path.inc index 994bc671c13..2484b8a744e 100644 --- a/llvm/lib/System/Win32/Path.inc +++ b/llvm/lib/System/Win32/Path.inc @@ -254,6 +254,13 @@ Path::exists() const { } bool +Path::isDirectory() const { + DWORD attr = GetFileAttributes(path.c_str()); + return (attr != INVALID_FILE_ATTRIBUTES) && + (attr & FILE_ATTRIBUTE_DIRECTORY); +} + +bool Path::canRead() const { // FIXME: take security attributes into account. DWORD attr = GetFileAttributes(path.c_str()); |