diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-11-14 23:30:38 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-11-14 23:30:38 +0000 |
commit | 2fbf978cb7eef93cc1ccb9035842dcd5282bc4d5 (patch) | |
tree | 381eadbf368b01583847b08a33c042eb2c588a6a /lib/System/Unix/Path.cpp | |
parent | b5a6f419d045bbc4b8d9dffab40c8d80cf025768 (diff) |
Implement functionality suggested from code review: getStatusInfo should
returnn false if the file doesn't exist rather than throw ane exception.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17809 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix/Path.cpp')
-rw-r--r-- | lib/System/Unix/Path.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/System/Unix/Path.cpp b/lib/System/Unix/Path.cpp index c6dbf87ed0..d2ba0f9035 100644 --- a/lib/System/Unix/Path.cpp +++ b/lib/System/Unix/Path.cpp @@ -239,8 +239,10 @@ Path::getLast() const { return path.substr(pos+1); } -void +bool Path::getStatusInfo(StatusInfo& info) { + if (!isFile() || !readable()) + return false; struct stat buf; if (0 != stat(path.c_str(), &buf)) { ThrowErrno(std::string("Can't get status: ")+path); @@ -253,6 +255,7 @@ Path::getStatusInfo(StatusInfo& info) { info.isDir = S_ISDIR(buf.st_mode); if (info.isDir && path[path.length()-1] != '/') path += '/'; + return true; } bool |