diff options
Diffstat (limited to 'indra/llvfs/lldir.cpp')
-rwxr-xr-x | indra/llvfs/lldir.cpp | 66 |
1 files changed, 64 insertions, 2 deletions
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 <boost/filesystem.hpp> #include <boost/foreach.hpp> #include <boost/range/begin.hpp> #include <boost/range/end.hpp> @@ -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<std::string> LLDir::getFilesInDir(const std::string &dirname) +{ + //Returns a vector of fullpath filenames. + + boost::filesystem::path p (dirname); + std::vector<std::string> 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; |