From 44b24340dcccf666c1ae19edeb67622f4aae9cca Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Fri, 13 Jan 2017 11:50:12 +0100 Subject: Crashdump: Make crash directory configurable Change-Id: I8106ec674080ede7072581dab2e6700040de5828 --- desktop/source/app/crashreport.cxx | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/desktop/source/app/crashreport.cxx b/desktop/source/app/crashreport.cxx index 04b234f38a75..9359113aee2f 100644 --- a/desktop/source/app/crashreport.cxx +++ b/desktop/source/app/crashreport.cxx @@ -82,22 +82,34 @@ void CrashReporter::writeCommonInfo() namespace { -OUString getCrashUserProfileDirectory() +OUString getCrashDirectory() { - OUString url("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/crash/"); - rtl::Bootstrap::expandMacros(url); - osl::Directory::create(url); + OUString aCrashURL; - OUString aProfilePath; - osl::FileBase::getSystemPathFromFileURL(url, aProfilePath); - return aProfilePath; + // First check whether a user-defined path is available (crashreport.ini) + OUString aCrashPath("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("crashreport") ":CrashDirectory}"); + rtl::Bootstrap::expandMacros(aCrashPath); + osl::FileBase::getFileURLFromSystemPath(aCrashPath, aCrashURL); + + // Fall back to user profile + if (aCrashPath.isEmpty()) + { + aCrashURL = "${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/crash"; + rtl::Bootstrap::expandMacros(aCrashURL); + } + + if (!aCrashURL.endsWith("/")) + aCrashURL += "/"; + osl::FileBase::RC rc = osl::Directory::create(aCrashURL); + osl::FileBase::getSystemPathFromFileURL(aCrashURL, aCrashPath); + return aCrashPath; } } void CrashReporter::updateMinidumpLocation() { - OUString aURL = getCrashUserProfileDirectory(); + OUString aURL = getCrashDirectory(); OString aOStringUrl = OUStringToOString(aURL, RTL_TEXTENCODING_UTF8); #if defined( UNX ) && !defined MACOSX && !defined IOS && !defined ANDROID @@ -115,7 +127,7 @@ void CrashReporter::storeExceptionHandler(google_breakpad::ExceptionHandler* pEx std::string CrashReporter::getIniFileName() { - OUString url = getCrashUserProfileDirectory() + "dump.ini"; + OUString url = getCrashDirectory() + "dump.ini"; OString aUrl = OUStringToOString(url, RTL_TEXTENCODING_UTF8); std::string aRet(aUrl.getStr()); return aRet; -- cgit