From 26f4c4a773a65f69396e740500b0c234a0ffa32e Mon Sep 17 00:00:00 2001 From: Latif Khalifa Date: Sun, 6 Oct 2013 08:11:07 +0200 Subject: [PATCH] Boost throws exceptions --- indra/llvfs/lldir.cpp | 72 ++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp index 60d3c775d..a93c833ba 100644 --- a/indra/llvfs/lldir.cpp +++ b/indra/llvfs/lldir.cpp @@ -133,47 +133,55 @@ S32 LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask) llassert(!"Invalid file mask"); } - LLDirIterator iter(dirname, mask); - while (iter.next(filename)) + try { - fullpath = add(dirname, filename); - - if(LLFile::isdir(fullpath)) + LLDirIterator iter(dirname, mask); + while (iter.next(filename)) { - // skipping directory traversal filenames - count++; - continue; - } + fullpath = add(dirname, filename); - S32 retry_count = 0; - while (retry_count < 5) - { - if (0 != LLFile::remove(fullpath)) + if(LLFile::isdir(fullpath)) { - retry_count++; - result = errno; - llwarns << "Problem removing " << fullpath << " - errorcode: " + // skipping directory traversal filenames + count++; + continue; + } + + S32 retry_count = 0; + while (retry_count < 5) + { + if (0 != LLFile::remove(fullpath)) + { + retry_count++; + result = errno; + llwarns << "Problem removing " << fullpath << " - errorcode: " << result << " attempt " << retry_count << llendl; - if(retry_count >= 5) - { - llwarns << "Failed to remove " << fullpath << llendl ; - return count ; - } + if(retry_count >= 5) + { + llwarns << "Failed to remove " << fullpath << llendl ; + return count ; + } - ms_sleep(100); - } - else - { - if (retry_count) - { - llwarns << "Successfully removed " << fullpath << llendl; + ms_sleep(100); } - break; - } + else + { + if (retry_count) + { + llwarns << "Successfully removed " << fullpath << llendl; + } + break; + } + } + count++; } - count++; } + catch(...) + { + llwarns << "Unable to remove some files from " + dirname << llendl; + } + return count; } @@ -189,7 +197,7 @@ U32 LLDir::deleteDirAndContents(const std::string& dir_name) } catch(const boost::filesystem::filesystem_error& e) { - llinfos << "boost::filesystem::remove_all(\"" + dir_name + "\") failed: '" + e.code().message() + "'" << llendl; + llwarns << "boost::filesystem::remove_all(\"" + dir_name + "\") failed: '" + e.code().message() + "'" << llendl; } return res;