diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-08-23 06:56:27 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-08-23 06:56:27 +0000 |
commit | 142ca8e81800ce6bcb511f3250bae23210d38ec8 (patch) | |
tree | b5edc0d2bd5c9a7216da68213db868e669d7b757 /lib/System | |
parent | e5c9cb5eb6bce502faaedea04014dab46f6540f4 (diff) | |
download | external_llvm-142ca8e81800ce6bcb511f3250bae23210d38ec8.zip external_llvm-142ca8e81800ce6bcb511f3250bae23210d38ec8.tar.gz external_llvm-142ca8e81800ce6bcb511f3250bae23210d38ec8.tar.bz2 |
For PR797:
Remove exception throwing from Path::getDirectoryContents and its users.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29841 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System')
-rw-r--r-- | lib/System/Unix/Path.inc | 13 | ||||
-rw-r--r-- | lib/System/Win32/Path.inc | 16 |
2 files changed, 18 insertions, 11 deletions
diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc index 7fc77a9..2b9f126 100644 --- a/lib/System/Unix/Path.inc +++ b/lib/System/Unix/Path.inc @@ -415,10 +415,12 @@ bool Path::makeExecutableOnDisk(std::string* ErrMsg) { } bool -Path::getDirectoryContents(std::set<Path>& result) const { +Path::getDirectoryContents(std::set<Path>& result, std::string* ErrMsg) const { DIR* direntries = ::opendir(path.c_str()); - if (direntries == 0) - ThrowErrno(path + ": can't open directory"); + if (direntries == 0) { + MakeErrMsg(ErrMsg, path + ": can't open directory"); + return true; + } std::string dirPath = path; if (!lastIsSlash(dirPath)) @@ -433,14 +435,15 @@ Path::getDirectoryContents(std::set<Path>& result) const { if (0 != lstat(aPath.path.c_str(), &st)) { if (S_ISLNK(st.st_mode)) continue; // dangling symlink -- ignore - ThrowErrno(aPath.path + ": can't determine file object type"); + MakeErrMsg(ErrMsg, aPath.path + ": can't determine file object type"); + return true; } result.insert(aPath); } } closedir(direntries); - return true; + return false; } bool diff --git a/lib/System/Win32/Path.inc b/lib/System/Win32/Path.inc index 2f2e852..913a409 100644 --- a/lib/System/Win32/Path.inc +++ b/lib/System/Win32/Path.inc @@ -353,9 +353,11 @@ bool Path::makeExecutableOnDisk(std::string* ErrMsg) { } bool -Path::getDirectoryContents(std::set<Path>& result) const { - if (!isDirectory()) - return false; +Path::getDirectoryContents(std::set<Path>& result, std::string* ErrMsg) const { + if (!isDirectory()) { + MakeErrMsg(ErrMsg, path + ": not a directory"); + return true; + } result.clear(); WIN32_FIND_DATA fd; @@ -369,7 +371,8 @@ Path::getDirectoryContents(std::set<Path>& result) const { if (h == INVALID_HANDLE_VALUE) { if (GetLastError() == ERROR_FILE_NOT_FOUND) return true; // not really an error, now is it? - ThrowError(path + ": Can't read directory: "); + MakeErrMsg(ErrMsg, path + ": Can't read directory: "); + return true; } do { @@ -384,9 +387,10 @@ Path::getDirectoryContents(std::set<Path>& result) const { FindClose(h); if (err != ERROR_NO_MORE_FILES) { SetLastError(err); - ThrowError(path + ": Can't read directory: "); + MakeErrMsg(ErrMsg, path + ": Can't read directory: "); + return true; } - return true; + return false; } bool |