mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-15 11:18:29 +12:00
Add support for non portable mode (#356)
This commit is contained in:
parent
2b9edced81
commit
d6ba61cf64
38 changed files with 233 additions and 163 deletions
|
@ -424,7 +424,7 @@ OnlineValidator Account::ValidateOnlineFiles() const
|
|||
{
|
||||
OnlineValidator result{};
|
||||
|
||||
const auto otp = ActiveSettings::GetPath("otp.bin");
|
||||
const auto otp = ActiveSettings::GetUserDataPath("otp.bin");
|
||||
if (!fs::exists(otp))
|
||||
result.otp = OnlineValidator::FileState::Missing;
|
||||
else if (fs::file_size(otp) != 1024)
|
||||
|
@ -432,7 +432,7 @@ OnlineValidator Account::ValidateOnlineFiles() const
|
|||
else
|
||||
result.otp = OnlineValidator::FileState::Ok;
|
||||
|
||||
const auto seeprom = ActiveSettings::GetPath("seeprom.bin");
|
||||
const auto seeprom = ActiveSettings::GetUserDataPath("seeprom.bin");
|
||||
if (!fs::exists(seeprom))
|
||||
result.seeprom = OnlineValidator::FileState::Missing;
|
||||
else if (fs::file_size(seeprom) != 512)
|
||||
|
|
|
@ -289,7 +289,7 @@ uint32 loadSharedData()
|
|||
for (sint32 i = 0; i < sizeof(shareddataDef) / sizeof(shareddataDef[0]); i++)
|
||||
{
|
||||
bool existsInMLC = fs::exists(ActiveSettings::GetMlcPath(shareddataDef[i].mlcPath));
|
||||
bool existsInResources = fs::exists(ActiveSettings::GetPath(shareddataDef[i].resourcePath));
|
||||
bool existsInResources = fs::exists(ActiveSettings::GetDataPath(shareddataDef[i].resourcePath));
|
||||
|
||||
if (!existsInMLC && !existsInResources)
|
||||
{
|
||||
|
@ -314,7 +314,7 @@ uint32 loadSharedData()
|
|||
// alternatively fall back to our shared fonts
|
||||
if (!fontFile)
|
||||
{
|
||||
path = ActiveSettings::GetPath(shareddataDef[i].resourcePath);
|
||||
path = ActiveSettings::GetDataPath(shareddataDef[i].resourcePath);
|
||||
fontFile = FileStream::openFile2(path);
|
||||
}
|
||||
if (!fontFile)
|
||||
|
@ -340,7 +340,7 @@ uint32 loadSharedData()
|
|||
return memory_getVirtualOffsetFromPointer(dataWritePtr);
|
||||
}
|
||||
// alternative method: load RAM dump
|
||||
const auto path = ActiveSettings::GetPath("shareddata.bin");
|
||||
const auto path = ActiveSettings::GetUserDataPath("shareddata.bin");
|
||||
FileStream* ramDumpFile = FileStream::openFile2(path);
|
||||
if (ramDumpFile)
|
||||
{
|
||||
|
|
|
@ -59,7 +59,7 @@ void KeyCache_Prepare()
|
|||
sKeyCachePrepared = true;
|
||||
g_keyCache.clear();
|
||||
// load keys
|
||||
auto keysPath = ActiveSettings::GetPath("keys.txt");
|
||||
auto keysPath = ActiveSettings::GetUserDataPath("keys.txt");
|
||||
FileStream* fs_keys = FileStream::openFile2(keysPath);
|
||||
if( !fs_keys )
|
||||
{
|
||||
|
|
|
@ -180,12 +180,12 @@ void gameProfile_load()
|
|||
|
||||
bool GameProfile::Load(uint64_t title_id)
|
||||
{
|
||||
auto gameProfilePath = ActiveSettings::GetPath("gameProfiles/{:016x}.ini", title_id);
|
||||
auto gameProfilePath = ActiveSettings::GetConfigPath("gameProfiles/{:016x}.ini", title_id);
|
||||
|
||||
std::optional<std::vector<uint8>> profileContents = FileStream::LoadIntoMemory(gameProfilePath);
|
||||
if (!profileContents)
|
||||
{
|
||||
gameProfilePath = ActiveSettings::GetPath("gameProfiles/default/{:016x}.ini", title_id);
|
||||
gameProfilePath = ActiveSettings::GetDataPath("gameProfiles/default/{:016x}.ini", title_id);
|
||||
profileContents = FileStream::LoadIntoMemory(gameProfilePath);
|
||||
if (!profileContents)
|
||||
return false;
|
||||
|
@ -276,7 +276,12 @@ bool GameProfile::Load(uint64_t title_id)
|
|||
|
||||
void GameProfile::Save(uint64_t title_id)
|
||||
{
|
||||
auto gameProfilePath = ActiveSettings::GetPath("gameProfiles/{:016x}.ini", title_id);
|
||||
auto gameProfileDir = ActiveSettings::GetConfigPath("gameProfiles");
|
||||
if (std::error_code ex_ec; !fs::exists(gameProfileDir, ex_ec) && !ex_ec) {
|
||||
std::error_code cr_ec;
|
||||
fs::create_directories(gameProfileDir, cr_ec);
|
||||
}
|
||||
auto gameProfilePath = gameProfileDir / fmt::format("{:016x}.ini", title_id);
|
||||
FileStream* fs = FileStream::createFile2(gameProfilePath);
|
||||
if (!fs)
|
||||
{
|
||||
|
|
|
@ -63,7 +63,7 @@ void GraphicPack2::LoadGraphicPack(fs::path graphicPackPath)
|
|||
void GraphicPack2::LoadAll()
|
||||
{
|
||||
std::error_code ec;
|
||||
fs::path basePath = ActiveSettings::GetPath("graphicPacks");
|
||||
fs::path basePath = ActiveSettings::GetUserDataPath("graphicPacks");
|
||||
for (fs::recursive_directory_iterator it(basePath, ec); it != end(it); ++it)
|
||||
{
|
||||
if (!it->is_directory(ec))
|
||||
|
@ -93,7 +93,7 @@ bool GraphicPack2::LoadGraphicPack(const std::wstring& filename, IniParser& rule
|
|||
if (it == config_entries.cend())
|
||||
{
|
||||
// check for relative path
|
||||
it = config_entries.find(MakeRelativePath(gp->GetFilename2()).lexically_normal());
|
||||
it = config_entries.find(MakeRelativePath(ActiveSettings::GetUserDataPath(), gp->GetFilename2()).lexically_normal());
|
||||
}
|
||||
|
||||
if (it != config_entries.cend())
|
||||
|
|
|
@ -197,17 +197,17 @@ void LatteShaderCache_load()
|
|||
LatteShaderCache_initCompileQueue();
|
||||
// create directories
|
||||
std::error_code ec;
|
||||
fs::create_directories(ActiveSettings::GetPath("shaderCache/transferable"), ec);
|
||||
fs::create_directories(ActiveSettings::GetPath("shaderCache/precompiled"), ec);
|
||||
fs::create_directories(ActiveSettings::GetCachePath("shaderCache/transferable"), ec);
|
||||
fs::create_directories(ActiveSettings::GetCachePath("shaderCache/precompiled"), ec);
|
||||
// initialize renderer specific caches
|
||||
if (g_renderer->GetType() == RendererAPI::Vulkan)
|
||||
RendererShaderVk::ShaderCacheLoading_begin(cacheTitleId);
|
||||
else if (g_renderer->GetType() == RendererAPI::OpenGL)
|
||||
RendererShaderGL::ShaderCacheLoading_begin(cacheTitleId);
|
||||
// get cache file name
|
||||
const auto pathGeneric = ActiveSettings::GetPath("shaderCache/transferable/{:016x}_shaders.bin", cacheTitleId);
|
||||
const auto pathGenericPre1_25_0 = ActiveSettings::GetPath("shaderCache/transferable/{:016x}.bin", cacheTitleId); // before 1.25.0
|
||||
const auto pathGenericPre1_16_0 = ActiveSettings::GetPath("shaderCache/transferable/{:08x}.bin", CafeSystem::GetRPXHashBase()); // before 1.16.0
|
||||
const auto pathGeneric = ActiveSettings::GetCachePath("shaderCache/transferable/{:016x}_shaders.bin", cacheTitleId);
|
||||
const auto pathGenericPre1_25_0 = ActiveSettings::GetCachePath("shaderCache/transferable/{:016x}.bin", cacheTitleId); // before 1.25.0
|
||||
const auto pathGenericPre1_16_0 = ActiveSettings::GetCachePath("shaderCache/transferable/{:08x}.bin", CafeSystem::GetRPXHashBase()); // before 1.16.0
|
||||
|
||||
LatteShaderCache_handleDeprecatedCacheFiles(pathGeneric, pathGenericPre1_25_0, pathGenericPre1_16_0);
|
||||
// calculate extraVersion for transferable and precompiled shader cache
|
||||
|
|
|
@ -279,7 +279,7 @@ void RendererShaderGL::ShaderCacheLoading_begin(uint64 cacheTitleId)
|
|||
{
|
||||
const uint32 cacheMagic = GeneratePrecompiledCacheId();
|
||||
const std::string cacheFilename = fmt::format("{:016x}_gl.bin", cacheTitleId);
|
||||
const std::wstring cachePath = ActiveSettings::GetPath("shaderCache/precompiled/{}", cacheFilename).generic_wstring();
|
||||
const std::wstring cachePath = ActiveSettings::GetCachePath("shaderCache/precompiled/{}", cacheFilename).generic_wstring();
|
||||
g_programBinaryCache = FileCache::Open(cachePath, true, cacheMagic);
|
||||
if (g_programBinaryCache == nullptr)
|
||||
cemuLog_log(LogType::Force, "Unable to open OpenGL precompiled cache {}", cacheFilename);
|
||||
|
|
|
@ -133,7 +133,7 @@ void Renderer::SaveScreenshot(const std::vector<uint8>& rgb_data, int width, int
|
|||
// save to png file
|
||||
if (save_screenshot)
|
||||
{
|
||||
fs::path screendir = ActiveSettings::GetPath("screenshots");
|
||||
fs::path screendir = ActiveSettings::GetUserDataPath("screenshots");
|
||||
if (!fs::exists(screendir))
|
||||
fs::create_directory(screendir);
|
||||
|
||||
|
|
|
@ -442,7 +442,7 @@ void RendererShaderVk::ShaderCacheLoading_begin(uint64 cacheTitleId)
|
|||
}
|
||||
uint32 spirvCacheMagic = GeneratePrecompiledCacheId();
|
||||
const std::string cacheFilename = fmt::format("{:016x}_spirv.bin", cacheTitleId);
|
||||
const std::wstring cachePath = ActiveSettings::GetPath("shaderCache/precompiled/{}", cacheFilename).generic_wstring();
|
||||
const std::wstring cachePath = ActiveSettings::GetCachePath("shaderCache/precompiled/{}", cacheFilename).generic_wstring();
|
||||
s_spirvCache = FileCache::Open(cachePath, true, spirvCacheMagic);
|
||||
if (s_spirvCache == nullptr)
|
||||
cemuLog_log(LogType::Force, "Unable to open SPIR-V cache {}", cacheFilename);
|
||||
|
|
|
@ -32,8 +32,8 @@ VulkanPipelineStableCache& VulkanPipelineStableCache::GetInstance()
|
|||
uint32 VulkanPipelineStableCache::BeginLoading(uint64 cacheTitleId)
|
||||
{
|
||||
std::error_code ec;
|
||||
fs::create_directories(ActiveSettings::GetPath("shaderCache/transferable"), ec);
|
||||
const auto pathCacheFile = ActiveSettings::GetPath("shaderCache/transferable/{:016x}_vkpipeline.bin", cacheTitleId);
|
||||
fs::create_directories(ActiveSettings::GetCachePath("shaderCache/transferable"), ec);
|
||||
const auto pathCacheFile = ActiveSettings::GetCachePath("shaderCache/transferable/{:016x}_vkpipeline.bin", cacheTitleId);
|
||||
|
||||
// init cache loader state
|
||||
g_vkCacheState.pipelineLoadIndex = 0;
|
||||
|
|
|
@ -2326,7 +2326,7 @@ void VulkanRenderer::WaitCommandBufferFinished(uint64 commandBufferId)
|
|||
|
||||
void VulkanRenderer::PipelineCacheSaveThread(size_t cache_size)
|
||||
{
|
||||
const auto dir = ActiveSettings::GetPath("shaderCache/driver/vk");
|
||||
const auto dir = ActiveSettings::GetCachePath("shaderCache/driver/vk");
|
||||
if (!fs::exists(dir))
|
||||
{
|
||||
try
|
||||
|
@ -2403,7 +2403,7 @@ void VulkanRenderer::PipelineCacheSaveThread(size_t cache_size)
|
|||
void VulkanRenderer::CreatePipelineCache()
|
||||
{
|
||||
std::vector<uint8_t> cacheData;
|
||||
const auto dir = ActiveSettings::GetPath("shaderCache/driver/vk");
|
||||
const auto dir = ActiveSettings::GetCachePath("shaderCache/driver/vk");
|
||||
if (fs::exists(dir))
|
||||
{
|
||||
const auto filename = dir / fmt::format("{:016x}.bin", CafeSystem::GetForegroundTitleId());
|
||||
|
|
|
@ -409,7 +409,7 @@ void memory_writeDumpFile(uint32 startAddr, uint32 size, const fs::path& path)
|
|||
void memory_createDump()
|
||||
{
|
||||
const uint32 pageSize = MemMapper::GetPageSize();
|
||||
fs::path path = ActiveSettings::GetPath("dump/ramDump{:}", (uint32)time(nullptr));
|
||||
fs::path path = ActiveSettings::GetUserDataPath("dump/ramDump{:}", (uint32)time(nullptr));
|
||||
fs::create_directories(path);
|
||||
|
||||
for (auto& itr : g_mmuRanges)
|
||||
|
|
|
@ -563,7 +563,7 @@ void iosuCrypto_loadSSLCertificates()
|
|||
void iosuCrypto_init()
|
||||
{
|
||||
// load OTP dump
|
||||
if (std::ifstream otp_file(ActiveSettings::GetPath("otp.bin"), std::ifstream::in | std::ios::binary); otp_file.is_open())
|
||||
if (std::ifstream otp_file(ActiveSettings::GetUserDataPath("otp.bin"), std::ifstream::in | std::ios::binary); otp_file.is_open())
|
||||
{
|
||||
otp_file.seekg(0, std::ifstream::end);
|
||||
const auto length = otp_file.tellg();
|
||||
|
@ -586,7 +586,7 @@ void iosuCrypto_init()
|
|||
hasOtpMem = false;
|
||||
}
|
||||
|
||||
if (std::ifstream seeprom_file(ActiveSettings::GetPath("seeprom.bin"), std::ifstream::in | std::ios::binary); seeprom_file.is_open())
|
||||
if (std::ifstream seeprom_file(ActiveSettings::GetUserDataPath("seeprom.bin"), std::ifstream::in | std::ios::binary); seeprom_file.is_open())
|
||||
{
|
||||
seeprom_file.seekg(0, std::ifstream::end);
|
||||
const auto length = seeprom_file.tellg();
|
||||
|
@ -630,13 +630,13 @@ sint32 iosuCrypt_checkRequirementsForOnlineMode(std::wstring& additionalErrorInf
|
|||
{
|
||||
std::error_code ec;
|
||||
// check if otp.bin is present
|
||||
const auto otp_file = ActiveSettings::GetPath("otp.bin");
|
||||
const auto otp_file = ActiveSettings::GetUserDataPath("otp.bin");
|
||||
if(!fs::exists(otp_file, ec))
|
||||
return IOS_CRYPTO_ONLINE_REQ_OTP_MISSING;
|
||||
if(fs::file_size(otp_file, ec) != 1024)
|
||||
return IOS_CRYPTO_ONLINE_REQ_OTP_CORRUPTED;
|
||||
// check if seeprom.bin is present
|
||||
const auto seeprom_file = ActiveSettings::GetPath("seeprom.bin");
|
||||
const auto seeprom_file = ActiveSettings::GetUserDataPath("seeprom.bin");
|
||||
if (!fs::exists(seeprom_file, ec))
|
||||
return IOS_CRYPTO_ONLINE_REQ_SEEPROM_MISSING;
|
||||
if (fs::file_size(seeprom_file, ec) != 512)
|
||||
|
|
|
@ -2116,7 +2116,7 @@ void RPLLoader_LoadDependency(rplDependency_t* dependency)
|
|||
// attempt to load rpl from Cemu's /cafeLibs/ directory
|
||||
if (ActiveSettings::LoadSharedLibrariesEnabled())
|
||||
{
|
||||
const auto filePath = ActiveSettings::GetPath("cafeLibs/{}", dependency->filepath);
|
||||
const auto filePath = ActiveSettings::GetUserDataPath("cafeLibs/{}", dependency->filepath);
|
||||
auto fileData = FileStream::LoadIntoMemory(filePath);
|
||||
if (fileData)
|
||||
{
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace coreinit
|
|||
return;
|
||||
|
||||
std::error_code ec;
|
||||
const auto path = ActiveSettings::GetPath("sdcard/");
|
||||
const auto path = ActiveSettings::GetUserDataPath("sdcard/");
|
||||
fs::create_directories(path, ec);
|
||||
FSCDeviceHostFS_Mount("/vol/external01", _pathToUtf8(path), FSC_PRIORITY_BASE);
|
||||
|
||||
|
@ -140,7 +140,7 @@ namespace coreinit
|
|||
return FS_RESULT::ERR_PLACEHOLDER;
|
||||
|
||||
std::error_code ec;
|
||||
const auto path = ActiveSettings::GetPath("sdcard/");
|
||||
const auto path = ActiveSettings::GetUserDataPath("sdcard/");
|
||||
fs::create_directories(path, ec);
|
||||
if (!FSCDeviceHostFS_Mount(mountPathOut, _pathToUtf8(path), FSC_PRIORITY_BASE))
|
||||
return FS_RESULT::ERR_PLACEHOLDER;
|
||||
|
|
|
@ -291,7 +291,7 @@ void TitleInfo::CalcUID()
|
|||
fs::path normalizedPath;
|
||||
if (m_fullPath.is_relative())
|
||||
{
|
||||
normalizedPath = ActiveSettings::GetPath();
|
||||
normalizedPath = ActiveSettings::GetUserDataPath();
|
||||
normalizedPath /= m_fullPath;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue