From 7705ec231c249d35dfb80b9364958d33b9689c95 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Sun, 14 Nov 2004 23:30:38 +0000 Subject: Implement functionality suggested from code review: getStatusInfo should returnn false if the file doesn't exist rather than throw ane exception. llvm-svn: 17809 --- llvm/lib/System/Unix/Path.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'llvm/lib/System/Unix/Path.cpp') 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 -- cgit v1.2.3