Skip to content

Commit

Permalink
feat: allow none as a value for data_dir and cache_dir to use t…
Browse files Browse the repository at this point in the history
…he browser's default path
  • Loading branch information
Bush2021 committed Oct 30, 2024
1 parent d05ee87 commit 603b5e9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
Binary file modified src/chrome++.ini
Binary file not shown.
41 changes: 21 additions & 20 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,30 @@ std::wstring GetCrCommandLine() {
return commandLine;
}
return GetIniString(L"General", L"CommandLine", L""); // Deprecated
return L"";
}

std::wstring GetDirPath(const std::wstring& dirType) {
std::wstring path = CanonicalizePath(GetAppDir() + L"\\..\\" + dirType);
std::wstring DirBuffer(MAX_PATH, '\0');
::GetPrivateProfileStringW(L"general", (dirType + L"_dir").c_str(),
path.c_str(), &DirBuffer[0], MAX_PATH,
kIniPath.c_str());
// Deprecated
if (DirBuffer[0] == 0) {
::GetPrivateProfileStringW(L"general", (dirType + L"dir").c_str(),
path.c_str(), &DirBuffer[0], MAX_PATH,
kIniPath.c_str());
}

std::wstring GetDirPath(const std::wstring& dir_type) {
std::wstring path = CanonicalizePath(GetAppDir() + L"\\..\\" + dir_type);
std::wstring dir_key = dir_type + L"_dir";
std::wstring dir_buffer = GetIniString(L"general", dir_key, path);

if (dir_buffer == L"none") {
return L"";
}
if (DirBuffer[0] == 0) {
DirBuffer = path;

if (dir_buffer.empty()) { // Deprecated
dir_key = dir_type + L"dir";
dir_buffer = GetIniString(L"general", dir_key, path);
}

if (dir_buffer.empty()) {
dir_buffer = path;
}

std::wstring ExpandedPath = ExpandEnvironmentPath(DirBuffer);
ReplaceStringIni(ExpandedPath, L"%app%", GetAppDir());
std::wstring Dir = GetAbsolutePath(ExpandedPath);
return Dir;
std::wstring expanded_path = ExpandEnvironmentPath(dir_buffer);
ReplaceStringIni(expanded_path, L"%app%", GetAppDir());
std::wstring dir = GetAbsolutePath(expanded_path);
return dir;
}

std::wstring GetUserDataDir() {
Expand Down
8 changes: 4 additions & 4 deletions src/portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ std::wstring GetCommand(LPWSTR param) {

args.push_back(L"--disable-features=WinSboxNoFakeGdiInit");

{
auto userdata = GetUserDataDir();
auto userdata = GetUserDataDir();
if (!userdata.empty()) {
args.push_back(L"--user-data-dir=" + userdata);
}

{
auto diskcache = GetDiskCacheDir();
auto diskcache = GetDiskCacheDir();
if (!diskcache.empty()) {
args.push_back(L"--disk-cache-dir=" + diskcache);
}

Expand Down

0 comments on commit 603b5e9

Please sign in to comment.