Skip to content

Commit

Permalink
Config: Allow specifying portable directory relative path in portable…
Browse files Browse the repository at this point in the history
….txt
  • Loading branch information
squidbus authored and F0bes committed Aug 21, 2024
1 parent ffe8d16 commit 83f9add
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pcsx2/Pcsx2Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ namespace EmuFolders
std::string Videos;

static bool ShouldUsePortableMode();
static std::string GetPortableModePath();
} // namespace EmuFolders

TraceFiltersEE::TraceFiltersEE()
Expand Down Expand Up @@ -1910,6 +1911,14 @@ bool EmuFolders::ShouldUsePortableMode()
return FileSystem::FileExists(Path::Combine(AppRoot, "portable.ini").c_str()) || FileSystem::FileExists(Path::Combine(AppRoot, "portable.txt").c_str());
}

std::string EmuFolders::GetPortableModePath()
{
const auto portable_txt_path = Path::Combine(AppRoot, "portable.txt");
const auto portable_path = FileSystem::ReadFileToString(portable_txt_path.c_str()).value_or("");
const auto trimmed_path = StringUtil::StripWhitespace(portable_path);
return std::string(trimmed_path);
}

bool EmuFolders::SetDataDirectory(Error* error)
{
if (!ShouldUsePortableMode())
Expand Down Expand Up @@ -1954,7 +1963,7 @@ bool EmuFolders::SetDataDirectory(Error* error)

// couldn't determine the data directory, or using portable mode? fallback to portable.
if (DataRoot.empty())
DataRoot = AppRoot;
DataRoot = Path::Combine(AppRoot, GetPortableModePath());

// inis is always below the data root
Settings = Path::Combine(DataRoot, "inis");
Expand Down

0 comments on commit 83f9add

Please sign in to comment.