mirror of
https://github.com/jpd002/Play-.git
synced 2025-04-28 13:47:57 +03:00
Change the way AppConfig base path is initialized.
This commit is contained in:
parent
0679518dec
commit
b4f635bdd2
11 changed files with 37 additions and 43 deletions
|
@ -1,47 +1,33 @@
|
|||
#include "AppConfig.h"
|
||||
#include "PathUtils.h"
|
||||
#include <iostream>
|
||||
#include <filesystem> // For file system operations
|
||||
|
||||
#define CONFIG_FILENAME ("config.xml")
|
||||
#define PORTABLE_BASE_DATA_PATH ("Play Data Files")
|
||||
#define BASE_DATA_PATH ("Play Data Files")
|
||||
#define CONFIG_FILENAME ("config.xml")
|
||||
|
||||
CAppConfig::CAppConfig()
|
||||
: CConfig(BuildConfigPath())
|
||||
{
|
||||
}
|
||||
|
||||
Framework::CConfig::PathType CAppConfig::GetBasePath()
|
||||
Framework::CConfig::PathType CAppConfig::BuildConfigPath()
|
||||
{
|
||||
// Check for the presence of the "portable.txt" file
|
||||
if(std::filesystem::exists("portable.txt"))
|
||||
return GetBasePath() / CONFIG_FILENAME;
|
||||
}
|
||||
|
||||
CAppConfigBasePath::CAppConfigBasePath()
|
||||
{
|
||||
//delete "read content portable.txt"
|
||||
|
||||
// If "portable.txt" is present, simply use the path specified in PORTABLE_BASE_DATA_PATH
|
||||
auto basePath = PORTABLE_BASE_DATA_PATH;
|
||||
|
||||
// Create the "Play Data Files" directory if it doesn't already exist
|
||||
std::filesystem::create_directories(basePath);
|
||||
|
||||
return basePath; // Return the base path without the complete path
|
||||
if(fs::exists("portable.txt"))
|
||||
{
|
||||
m_basePath = BASE_DATA_PATH;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If "portable.txt" is absent, use the original code for the base directory path
|
||||
auto result = Framework::PathUtils::GetPersonalDataPath() / BASE_DATA_PATH;
|
||||
|
||||
// Create the "Play Data Files" directory if it doesn't already exist
|
||||
Framework::PathUtils::EnsurePathExists(result);
|
||||
|
||||
return result;
|
||||
m_basePath = Framework::PathUtils::GetPersonalDataPath() / BASE_DATA_PATH;
|
||||
}
|
||||
Framework::PathUtils::EnsurePathExists(m_basePath);
|
||||
}
|
||||
|
||||
Framework::CConfig::PathType CAppConfig::BuildConfigPath()
|
||||
fs::path CAppConfigBasePath::GetBasePath() const
|
||||
{
|
||||
auto basePath(GetBasePath());
|
||||
// "config.xml" is located in the directory of the base path
|
||||
return basePath / CONFIG_FILENAME;
|
||||
return m_basePath;
|
||||
}
|
||||
|
|
|
@ -3,14 +3,22 @@
|
|||
#include "Config.h"
|
||||
#include "Singleton.h"
|
||||
|
||||
class CAppConfig : public Framework::CConfig, public CSingleton<CAppConfig>
|
||||
class CAppConfigBasePath
|
||||
{
|
||||
public:
|
||||
CAppConfigBasePath();
|
||||
fs::path GetBasePath() const;
|
||||
|
||||
private:
|
||||
fs::path m_basePath;
|
||||
};
|
||||
|
||||
class CAppConfig : public CAppConfigBasePath, public Framework::CConfig, public CSingleton<CAppConfig>
|
||||
{
|
||||
public:
|
||||
CAppConfig();
|
||||
virtual ~CAppConfig() = default;
|
||||
|
||||
static CConfig::PathType GetBasePath();
|
||||
|
||||
private:
|
||||
static CConfig::PathType BuildConfigPath();
|
||||
CConfig::PathType BuildConfigPath();
|
||||
};
|
||||
|
|
|
@ -31,14 +31,14 @@ std::unique_ptr<CInputConfig> CInputConfig::LoadProfile(std::string name)
|
|||
|
||||
Framework::CConfig::PathType CInputConfig::GetProfilePath()
|
||||
{
|
||||
auto profile_path = CAppConfig::GetBasePath() / PROFILE_PATH;
|
||||
auto profile_path = CAppConfig::GetInstance().GetBasePath() / PROFILE_PATH;
|
||||
Framework::PathUtils::EnsurePathExists(profile_path);
|
||||
return profile_path;
|
||||
}
|
||||
|
||||
Framework::CConfig::PathType CInputConfig::GetProfile(std::string name)
|
||||
{
|
||||
auto profile_path = CAppConfig::GetBasePath() / PROFILE_PATH;
|
||||
auto profile_path = CAppConfig::GetInstance().GetBasePath() / PROFILE_PATH;
|
||||
Framework::PathUtils::EnsurePathExists(profile_path);
|
||||
profile_path /= name;
|
||||
profile_path.replace_extension(".xml");
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
CLog::CLog()
|
||||
{
|
||||
#ifndef DISABLE_LOGGING
|
||||
m_logBasePath = CAppConfig::GetBasePath() / LOG_PATH;
|
||||
m_logBasePath = CAppConfig::GetInstance().GetBasePath() / LOG_PATH;
|
||||
Framework::PathUtils::EnsurePathExists(m_logBasePath);
|
||||
CAppConfig::GetInstance().RegisterPreferenceBoolean(PREF_LOG_SHOWPRINTS, false);
|
||||
m_showPrints = CAppConfig::GetInstance().GetPreferenceBoolean(PREF_LOG_SHOWPRINTS);
|
||||
|
|
|
@ -75,7 +75,7 @@ CPS2VM::CPS2VM()
|
|||
auto setting = basicDirectorySetting.first;
|
||||
auto path = basicDirectorySetting.second;
|
||||
|
||||
auto absolutePath = CAppConfig::GetBasePath() / path;
|
||||
auto absolutePath = CAppConfig::GetInstance().GetBasePath() / path;
|
||||
Framework::PathUtils::EnsurePathExists(absolutePath);
|
||||
CAppConfig::GetInstance().RegisterPreferencePath(setting, absolutePath);
|
||||
|
||||
|
@ -287,7 +287,7 @@ void CPS2VM::Destroy()
|
|||
|
||||
fs::path CPS2VM::GetStateDirectoryPath()
|
||||
{
|
||||
return CAppConfig::GetBasePath() / fs::path("states/");
|
||||
return CAppConfig::GetInstance().GetBasePath() / fs::path("states/");
|
||||
}
|
||||
|
||||
fs::path CPS2VM::GenerateStatePath(unsigned int slot) const
|
||||
|
|
|
@ -33,7 +33,7 @@ CScreenShotUtils::Connection CScreenShotUtils::TriggerGetScreenshot(CPS2VM* virt
|
|||
|
||||
fs::path CScreenShotUtils::GetScreenShotDirectoryPath()
|
||||
{
|
||||
auto screenshotpath(CAppConfig::GetBasePath() / fs::path("screenshots"));
|
||||
auto screenshotpath(CAppConfig::GetInstance().GetBasePath() / fs::path("screenshots"));
|
||||
Framework::PathUtils::EnsurePathExists(screenshotpath);
|
||||
return screenshotpath;
|
||||
}
|
||||
|
|
|
@ -775,7 +775,7 @@ void CSubSystem::FlushInstructionCache()
|
|||
|
||||
void CSubSystem::LoadBIOS()
|
||||
{
|
||||
auto biosPath = CAppConfig::GetBasePath() / "bios/scph10000.bin";
|
||||
auto biosPath = CAppConfig::GetInstance().GetBasePath() / "bios/scph10000.bin";
|
||||
auto biosStream = Framework::CreateInputStdStream(biosPath.native());
|
||||
biosStream.Read(m_bios, PS2::EE_BIOS_SIZE);
|
||||
}
|
||||
|
|
|
@ -109,8 +109,8 @@ CIoman::CIoman(CIopBios& bios, uint8* ram)
|
|||
{
|
||||
try
|
||||
{
|
||||
auto stdoutPath = CAppConfig::GetBasePath() / "ps2_stdout.txt";
|
||||
auto stderrPath = CAppConfig::GetBasePath() / "ps2_stderr.txt";
|
||||
auto stdoutPath = CAppConfig::GetInstance().GetBasePath() / "ps2_stdout.txt";
|
||||
auto stderrPath = CAppConfig::GetInstance().GetBasePath() / "ps2_stderr.txt";
|
||||
|
||||
m_files[FID_STDOUT] = FileInfo{new Framework::CStdStream(fopen(stdoutPath.string().c_str(), "ab"))};
|
||||
m_files[FID_STDERR] = FileInfo{new Framework::CStdStream(fopen(stderrPath.string().c_str(), "ab"))};
|
||||
|
|
|
@ -738,7 +738,7 @@ void CNamcoArcade::ProcessAcFlashCommand(const SIFCMDHEADER*, CSifMan& sifMan)
|
|||
|
||||
fs::path CNamcoArcade::GetArcadeSavePath()
|
||||
{
|
||||
return CAppConfig::GetBasePath() / fs::path("arcadesaves");
|
||||
return CAppConfig::GetInstance().GetBasePath() / fs::path("arcadesaves");
|
||||
}
|
||||
|
||||
void CNamcoArcade::ProcessMemRequest(uint8* ram, uint32 infoPtr)
|
||||
|
|
|
@ -33,7 +33,7 @@ void CoverUtils::PopulateCache(std::vector<BootablesDb::Bootable> bootables)
|
|||
m_lock.lock();
|
||||
PopulatePlaceholderCover();
|
||||
|
||||
auto coverpath(CAppConfig::GetBasePath() / fs::path("covers"));
|
||||
auto coverpath(CAppConfig::GetInstance().GetBasePath() / fs::path("covers"));
|
||||
Framework::PathUtils::EnsurePathExists(coverpath);
|
||||
|
||||
auto itr = CoverUtils::cache.find("PH");
|
||||
|
|
|
@ -236,7 +236,7 @@ void FetchGameTitles()
|
|||
|
||||
void FetchGameCovers()
|
||||
{
|
||||
auto coverpath(CAppConfig::GetBasePath() / fs::path("covers"));
|
||||
auto coverpath(CAppConfig::GetInstance().GetBasePath() / fs::path("covers"));
|
||||
Framework::PathUtils::EnsurePathExists(coverpath);
|
||||
|
||||
auto bootables = BootablesDb::CClient::GetInstance().GetBootables();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue