diff options
author | Aura Linden <aura@lindenlab.com> | 2014-03-07 14:58:22 -0800 |
---|---|---|
committer | Aura Linden <aura@lindenlab.com> | 2014-03-07 14:58:22 -0800 |
commit | d2bb4dae980a887a30b206875d8f9419901ed66a (patch) | |
tree | dec6222ed82c5e105b69ae9ec64e5f379051734d /indra/llvfs | |
parent | 8fd270af1cb7ee2cad7c47909b308ef31caf4cd3 (diff) |
Fixes for crash reporter startup race condition, crash reporter CPU use, Secondlife.log filehandle, XP Crash.
Diffstat (limited to 'indra/llvfs')
-rwxr-xr-x | indra/llvfs/lldir.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp index ccdfd2ab3c..0d65c3f8c3 100755 --- a/indra/llvfs/lldir.cpp +++ b/indra/llvfs/lldir.cpp @@ -187,8 +187,30 @@ S32 LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask) U32 LLDir::deleteDirAndContents(const std::string& dir_name) { - //Removes the directory and its contents. Returns number of files removed. - return boost::filesystem::remove_all(dir_name); + //Removes the directory and its contents. Returns number of files deleted. + + U32 num_deleted = 0; + + try + { + boost::filesystem::path dir_path(dir_name); + if (boost::filesystem::exists (dir_path)) + { + if (!boost::filesystem::is_empty (dir_path)) + { // Directory has content + num_deleted = boost::filesystem::remove_all (dir_path); + } + else + { // Directory is empty + boost::filesystem::remove (dir_path); + } + } + } + catch (boost::filesystem::filesystem_error &er) + { + llwarns << "Failed to delete " << dir_name << " with error " << er.code().message() << llendl; + } + return num_deleted; } const std::string LLDir::findFile(const std::string &filename, |