Breakpad3: WIP, minidump files created
TODO: re-work sending crash logs get rid of standalone loggers
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
|
||||
/**
|
||||
* @file lldir.cpp
|
||||
* @brief implementation of directory utilities base class
|
||||
@@ -42,6 +43,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>
|
||||
@@ -69,6 +71,8 @@ LLDir_Linux gDirUtil;
|
||||
|
||||
LLDir *gDirUtilp = (LLDir *)&gDirUtil;
|
||||
|
||||
static const char* const empty = "";
|
||||
std::string LLDir::sDumpDir = "";
|
||||
LLDir::LLDir()
|
||||
: mAppName(""),
|
||||
mExecutablePathAndName(""),
|
||||
@@ -89,7 +93,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().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
S32 LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask)
|
||||
{
|
||||
S32 count = 0;
|
||||
@@ -148,6 +177,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,
|
||||
@@ -235,6 +270,31 @@ 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;
|
||||
@@ -396,12 +456,29 @@ 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;
|
||||
|
||||
case LL_PATH_PER_SL_ACCOUNT:
|
||||
prefix = getLindenUserDir();
|
||||
if (prefix.empty())
|
||||
{
|
||||
// if we're asking for the per-SL-account directory but we haven't
|
||||
// logged in yet (or otherwise don't know the account name from
|
||||
// which to build this string), then intentionally return a blank
|
||||
// string to the caller and skip the below warning about a blank
|
||||
// prefix.
|
||||
LL_DEBUGS("LLDir") << "getLindenUserDir() not yet set: "
|
||||
<< ELLPathToString(location)
|
||||
<< ", '" << subdir1 << "', '" << subdir2 << "', '" << in_filename
|
||||
<< "' => ''" << LL_ENDL;
|
||||
return std::string();
|
||||
}
|
||||
break;
|
||||
|
||||
case LL_PATH_CHAT_LOGS:
|
||||
|
||||
@@ -53,6 +53,7 @@ typedef enum ELLPath
|
||||
LL_PATH_EXECUTABLE = 16,
|
||||
LL_PATH_DEFAULT_SKIN = 17,
|
||||
LL_PATH_FONTS = 18,
|
||||
LL_PATH_DUMP = 19,
|
||||
LL_PATH_LAST
|
||||
} ELLPath;
|
||||
|
||||
@@ -71,7 +72,8 @@ class LLDir
|
||||
const std::string& app_read_only_data_dir = "") = 0;
|
||||
|
||||
virtual S32 deleteFilesInDir(const std::string &dirname, const std::string &mask);
|
||||
|
||||
U32 deleteDirAndContents(const std::string& dir_name);
|
||||
std::vector<std::string> getFilesInDir(const std::string &dirname);
|
||||
// pure virtual functions
|
||||
virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask) = 0;
|
||||
|
||||
@@ -94,6 +96,7 @@ class LLDir
|
||||
const std::string &getOSUserAppDir() const; // Location of the os-specific user app dir
|
||||
const std::string &getLindenUserDir(bool empty_ok = false) const; // Location of the Linden user dir.
|
||||
const std::string &getChatLogsDir() const; // Location of the chat logs dir.
|
||||
const std::string &getDumpDir() const; // Location of the per-run dump dir.
|
||||
const std::string &getPerAccountChatLogsDir() const; // Location of the per account chat logs dir.
|
||||
const std::string &getTempDir() const; // Common temporary directory
|
||||
const std::string getCacheDir(bool get_default = false) const; // Location of the cache.
|
||||
@@ -128,6 +131,7 @@ class LLDir
|
||||
// For producing safe download file names from potentially unsafe ones
|
||||
static std::string getScrubbedFileName(const std::string uncleanFileName);
|
||||
static std::string getForbiddenFileChars();
|
||||
void setDumpDir( const std::string& path );
|
||||
|
||||
virtual void setChatLogsDir(const std::string &path); // Set the chat logs dir to this user's dir
|
||||
virtual void setPerAccountChatLogsDir(const std::string &grid, const std::string &first, const std::string &last); // Set the per user chat log directory.
|
||||
@@ -173,6 +177,7 @@ protected:
|
||||
std::string mDefaultSkinDir; // Location for default skin info.
|
||||
std::string mUserSkinDir; // Location for user-modified skin info.
|
||||
std::string mLLPluginDir; // Location for plugins and plugin shell
|
||||
static std::string sDumpDir; // Per-run crash report subdir of log directory.
|
||||
};
|
||||
|
||||
void dir_exists_or_crash(const std::string &dir_name);
|
||||
|
||||
Reference in New Issue
Block a user