consolidate code and rename for clarity
This commit is contained in:
parent
c620d0de05
commit
e7bb553d3b
3 changed files with 20 additions and 35 deletions
|
@ -4,7 +4,10 @@
|
|||
|
||||
#include "brightray/browser/browser_main_parts.h"
|
||||
|
||||
#if defined(OSX_POSIX)
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <string>
|
||||
|
||||
|
@ -60,8 +63,6 @@
|
|||
|
||||
namespace brightray {
|
||||
|
||||
void OverrideMacAppLogsPath();
|
||||
|
||||
namespace {
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
@ -163,41 +164,26 @@ BrowserMainParts::BrowserMainParts() {
|
|||
BrowserMainParts::~BrowserMainParts() {
|
||||
}
|
||||
|
||||
void OverrideWinAppLogsPath() {
|
||||
int status;
|
||||
std::string appName = GetApplicationName();
|
||||
std::string logPath = "%HOMEDRIVE%%HOMEPATH%\\AppData\\Roaming\\";
|
||||
std::string appLogPath = logPath + appName + "\\logs";
|
||||
|
||||
status = mkdir(appLogPath.c_str(), S_IRWXU | S_IRGRP | S_IROTH);
|
||||
|
||||
PathService::Override(DIR_APP_LOGS, base::FilePath(appLogPath));
|
||||
}
|
||||
|
||||
void OverrideLinuxAppLogsPath() {
|
||||
int status;
|
||||
std::string appName = GetApplicationName();
|
||||
std::string homePath = std::string(getenv("HOME"));
|
||||
std::string appLogPath = homePath + "/.config/" + appName + "/logs";
|
||||
|
||||
status = mkdir(appLogPath.c_str(), S_IRWXU | S_IRGRP | S_IROTH);
|
||||
|
||||
PathService::Override(DIR_APP_LOGS, base::FilePath(appLogPath));
|
||||
#if defined(OS_WIN) || defined(OS_LINUX)
|
||||
void OverrideAppLogsPath() {
|
||||
#if defined(OS_WIN)
|
||||
std::string app_name = GetApplicationName();
|
||||
std::string log_path = "%HOMEDRIVE%%HOMEPATH%\\AppData\\Roaming\\";
|
||||
std::string app_log_path = log_path + app_name + "\\logs";
|
||||
#else
|
||||
std::string app_name = GetApplicationName();
|
||||
std::string home_path = std::string(getenv("HOME"));
|
||||
std::string app_log_path = home_path + "/.config/" + app_name + "/logs";
|
||||
#endif
|
||||
PathService::Override(DIR_APP_LOGS, base::FilePath(app_log_path));
|
||||
}
|
||||
#endif
|
||||
|
||||
void BrowserMainParts::PreEarlyInitialization() {
|
||||
std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
|
||||
feature_list->InitializeFromCommandLine("", "");
|
||||
base::FeatureList::SetInstance(std::move(feature_list));
|
||||
#if defined(OS_MACOSX)
|
||||
OverrideMacAppLogsPath();
|
||||
#endif
|
||||
#if defined(OS_LINUX)
|
||||
OverrideLinuxAppLogsPath();
|
||||
#endif
|
||||
#if defined(OS_WIN)
|
||||
OverrideWinAppLogsPath();
|
||||
#endif
|
||||
OverrideAppLogsPath();
|
||||
#if defined(USE_X11)
|
||||
views::LinuxUI::SetInstance(BuildGtkUi());
|
||||
OverrideLinuxAppDataPath();
|
||||
|
|
|
@ -47,6 +47,7 @@ class BrowserMainParts : public content::BrowserMainParts {
|
|||
private:
|
||||
#if defined(OS_MACOSX)
|
||||
void InitializeMainNib();
|
||||
void OverrideAppLogsPath();
|
||||
#endif
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
|
|
|
@ -6,16 +6,14 @@
|
|||
|
||||
namespace brightray {
|
||||
|
||||
void OverrideMacAppLogsPath() {
|
||||
void BrowserMainParts::OverrideAppLogsPath() {
|
||||
base::FilePath path;
|
||||
NSString* bundleName = [[[NSBundle mainBundle] infoDictionary]
|
||||
objectForKey:@"CFBundleName"];
|
||||
NSString* logsPath = [NSString stringWithFormat:@"Library/Logs/%@",bundleName];
|
||||
|
||||
NSString* libraryPath = [NSHomeDirectory() stringByAppendingPathComponent:logsPath];
|
||||
std::string libPathString = std::string([libraryPath UTF8String]);
|
||||
|
||||
PathService::Override(DIR_APP_LOGS, base::FilePath(libPathString));
|
||||
PathService::Override(DIR_APP_LOGS, base::FilePath([libraryPath UTF8String]));
|
||||
}
|
||||
|
||||
// Replicates NSApplicationMain, but doesn't start a run loop.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue