From 680934812598d2c9116303f3245e7a9d60ff58bf Mon Sep 17 00:00:00 2001 From: Aura Linden Date: Tue, 3 Dec 2013 17:06:06 -0800 Subject: Creating a cleaner branch --- indra/llvfs/lldir.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) (limited to 'indra/llvfs/lldir.cpp') diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp index 6899e9a44a..ccdfd2ab3c 100755 --- a/indra/llvfs/lldir.cpp +++ b/indra/llvfs/lldir.cpp @@ -42,6 +42,7 @@ #include "lldiriterator.h" #include "stringize.h" +#include #include #include #include @@ -76,6 +77,7 @@ const char *LLDir::SKINBASE = ""; static const char* const empty = ""; +std::string LLDir::sDumpDir = ""; LLDir::LLDir() : mAppName(""), @@ -99,7 +101,32 @@ LLDir::~LLDir() { } - +std::vector LLDir::getFilesInDir(const std::string &dirname) +{ + //Returns a vector of fullpath filenames. + + boost::filesystem::path p (dirname); + std::vector v; + + if (exists(p)) + { + if (is_directory(p)) + { + boost::filesystem::directory_iterator end_iter; + for (boost::filesystem::directory_iterator dir_itr(p); + dir_itr != end_iter; + ++dir_itr) + { + if (boost::filesystem::is_regular_file(dir_itr->status())) + { + v.push_back(dir_itr->path().filename().string()); + } + } + } + } + return v; +} + S32 LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask) { S32 count = 0; @@ -158,6 +185,12 @@ S32 LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask) return count; } +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); +} + const std::string LLDir::findFile(const std::string &filename, const std::string& searchPath1, const std::string& searchPath2, @@ -244,11 +277,36 @@ const std::string &LLDir::getLindenUserDir() const return mLindenUserDir; } -const std::string &LLDir::getChatLogsDir() const +const std::string& LLDir::getChatLogsDir() const { return mChatLogsDir; } +void LLDir::setDumpDir( const std::string& path ) +{ + LLDir::sDumpDir = path; + if (! sDumpDir.empty() && sDumpDir.rbegin() == mDirDelimiter.rbegin() ) + { + sDumpDir.erase(sDumpDir.size() -1); + } +} + +const std::string &LLDir::getDumpDir() const +{ + if (sDumpDir.empty() ) + { + LLUUID uid; + uid.generate(); + + sDumpDir = gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "") + + "dump-" + uid.asString(); + + dir_exists_or_crash(sDumpDir); + } + + return LLDir::sDumpDir; +} + const std::string &LLDir::getPerAccountChatLogsDir() const { return mPerAccountChatLogsDir; @@ -420,6 +478,10 @@ std::string LLDir::getExpandedFilename(ELLPath location, const std::string& subd prefix = getCacheDir(); break; + case LL_PATH_DUMP: + prefix=getDumpDir(); + break; + case LL_PATH_USER_SETTINGS: prefix = add(getOSUserAppDir(), "user_settings"); break; -- cgit v1.2.3 From d2bb4dae980a887a30b206875d8f9419901ed66a Mon Sep 17 00:00:00 2001 From: Aura Linden Date: Fri, 7 Mar 2014 14:58:22 -0800 Subject: Fixes for crash reporter startup race condition, crash reporter CPU use, Secondlife.log filehandle, XP Crash. --- indra/llvfs/lldir.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'indra/llvfs/lldir.cpp') 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, -- cgit v1.2.3