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 | 7705ec231c249d35dfb80b9364958d33b9689c95 (patch) | |
tree | 3600a0ed1a33e7efcd947c0445dd4f174177f59e /llvm/lib/System/Unix/Path.cpp | |
parent | e554760178473d1344fb6fd290ea01f7d93e510e (diff) | |
download | bcm5719-llvm-7705ec231c249d35dfb80b9364958d33b9689c95.tar.gz bcm5719-llvm-7705ec231c249d35dfb80b9364958d33b9689c95.zip |
Implement functionality suggested from code review: getStatusInfo should
returnn false if the file doesn't exist rather than throw ane exception.
llvm-svn: 17809
Diffstat (limited to 'llvm/lib/System/Unix/Path.cpp')
-rw-r--r-- | llvm/lib/System/Unix/Path.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/System/Unix/Path.cpp b/llvm/lib/System/Unix/Path.cpp index c6dbf87ed0b..d2ba0f90359 100644 --- a/llvm/lib/System/Unix/Path.cpp +++ b/llvm/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 |