Rename path _utf8Wrapper to _utf8ToPath for better clarity

This commit is contained in:
Exzap 2022-09-09 23:48:52 +02:00
parent 168ecf8825
commit 680beaaf21
19 changed files with 60 additions and 67 deletions

View file

@ -209,7 +209,7 @@ void InfoLog_TitleLoaded()
fs::path effectiveSavePath = getTitleSavePath();
std::error_code ec;
const bool saveDirExists = fs::exists(effectiveSavePath, ec);
cemuLog_force("Save path: {}{}", _utf8Wrapper(effectiveSavePath), saveDirExists ? "" : " (not present)");
cemuLog_force("Save path: {}{}", _pathToUtf8(effectiveSavePath), saveDirExists ? "" : " (not present)");
// log shader cache name
cemuLog_log(LogType::Force, "Shader cache file: shaderCache/transferable/{:016x}.bin", titleId);
@ -617,7 +617,7 @@ namespace CafeSystem
sLaunchModeIsStandalone = true;
cemuLog_log(LogType::Force, "Launching executable in standalone mode due to incorrect layout or missing meta files");
fs::path executablePath = path;
std::string dirName = _utf8Wrapper(executablePath.parent_path().filename());
std::string dirName = _pathToUtf8(executablePath.parent_path().filename());
if (boost::iequals(dirName, "code"))
{
// check for content folder
@ -626,18 +626,18 @@ namespace CafeSystem
if (fs::is_directory(contentPath, ec))
{
// mounting content folder
bool r = FSCDeviceHostFS_Mount(std::string("/vol/content").c_str(), _utf8Wrapper(contentPath), FSC_PRIORITY_BASE);
bool r = FSCDeviceHostFS_Mount(std::string("/vol/content").c_str(), _pathToUtf8(contentPath), FSC_PRIORITY_BASE);
if (!r)
{
cemuLog_log(LogType::Force, "Failed to mount {}", _utf8Wrapper(contentPath).c_str());
cemuLog_log(LogType::Force, "Failed to mount {}", _pathToUtf8(contentPath));
return STATUS_CODE::UNABLE_TO_MOUNT;
}
}
}
// mount code folder to a virtual temporary path
FSCDeviceHostFS_Mount(std::string("/internal/code/").c_str(), _utf8Wrapper(executablePath.parent_path()), FSC_PRIORITY_BASE);
FSCDeviceHostFS_Mount(std::string("/internal/code/").c_str(), _pathToUtf8(executablePath.parent_path()), FSC_PRIORITY_BASE);
std::string internalExecutablePath = "/internal/code/";
internalExecutablePath.append(_utf8Wrapper(executablePath.filename()));
internalExecutablePath.append(_pathToUtf8(executablePath.filename()));
_pathToExecutable = internalExecutablePath;
// since a lot of systems (including save folder location) rely on a TitleId, we derive a placeholder id from the executable hash
auto execData = fsc_extractFile(_pathToExecutable.c_str());

View file

@ -127,7 +127,7 @@ bool FSCVirtualFile_Host::fscDirNext(FSCDirEntry* dirEntry)
m_dirIterator.reset(new fs::directory_iterator(*m_path));
if (!m_dirIterator)
{
cemuLog_force("Failed to iterate directory: {}", _utf8Wrapper(m_path->generic_u8string()));
cemuLog_force("Failed to iterate directory: {}", _pathToUtf8(*m_path));
return false;
}
}
@ -175,14 +175,14 @@ FSCVirtualFile* FSCVirtualFile_Host::OpenFile(const fs::path& path, FSC_ACCESS_F
cemu_assert_debug(writeAccessRequested);
fs = FileStream::createFile2(path);
if (!fs)
cemuLog_force("FSC: File create failed for {}", _utf8Wrapper(path));
cemuLog_force("FSC: File create failed for {}", _pathToUtf8(path));
}
}
else if (HAS_FLAG(accessFlags, FSC_ACCESS_FLAG::FILE_ALWAYS_CREATE))
{
fs = FileStream::createFile2(path);
if (!fs)
cemuLog_force("FSC: File create failed for {}", _utf8Wrapper(path));
cemuLog_force("FSC: File create failed for {}", _pathToUtf8(path));
}
else
{
@ -293,8 +293,8 @@ public:
void fscDeviceHostFS_mapBaseDirectories_deprecated()
{
const auto mlc = ActiveSettings::GetMlcPath();
fsc_mount("/cemuBossStorage/", _utf8Wrapper(mlc / "usr/boss/"), &fscDeviceHostFSC::instance(), NULL, FSC_PRIORITY_BASE);
fsc_mount("/vol/storage_mlc01/", _utf8Wrapper(mlc / ""), &fscDeviceHostFSC::instance(), NULL, FSC_PRIORITY_BASE);
fsc_mount("/cemuBossStorage/", _pathToUtf8(mlc / "usr/boss/"), &fscDeviceHostFSC::instance(), NULL, FSC_PRIORITY_BASE);
fsc_mount("/vol/storage_mlc01/", _pathToUtf8(mlc / ""), &fscDeviceHostFSC::instance(), NULL, FSC_PRIORITY_BASE);
}
bool FSCDeviceHostFS_Mount(std::string_view mountPath, std::string_view hostTargetPath, sint32 priority)

View file

@ -31,12 +31,12 @@ void GraphicPack2::LoadGraphicPack(fs::path graphicPackPath)
if (!iniParser.NextSection())
{
cemuLog_force("{}: Does not contain any sections", _utf8Wrapper(rulesPath));
cemuLog_force("{}: Does not contain any sections", _pathToUtf8(rulesPath));
return;
}
if (!boost::iequals(iniParser.GetCurrentSectionName(), "Definition"))
{
cemuLog_force("{}: [Definition] must be the first section", _utf8Wrapper(rulesPath));
cemuLog_force("{}: [Definition] must be the first section", _pathToUtf8(rulesPath));
return;
}
@ -47,7 +47,7 @@ void GraphicPack2::LoadGraphicPack(fs::path graphicPackPath)
auto [ptr, ec] = std::from_chars(option_version->data(), option_version->data() + option_version->size(), versionNum);
if (ec != std::errc{})
{
cemuLog_force("{}: Unable to parse version", _utf8Wrapper(rulesPath));
cemuLog_force("{}: Unable to parse version", _pathToUtf8(rulesPath));
return;
}
@ -57,7 +57,7 @@ void GraphicPack2::LoadGraphicPack(fs::path graphicPackPath)
return;
}
}
cemuLog_force("{}: Outdated graphic pack", _utf8Wrapper(rulesPath));
cemuLog_force("{}: Outdated graphic pack", _pathToUtf8(rulesPath));
}
void GraphicPack2::LoadAll()

View file

@ -109,7 +109,7 @@ namespace coreinit
std::error_code ec;
const auto path = ActiveSettings::GetPath("sdcard/");
fs::create_directories(path, ec);
FSCDeviceHostFS_Mount("/vol/external01", _utf8Wrapper(path), FSC_PRIORITY_BASE);
FSCDeviceHostFS_Mount("/vol/external01", _pathToUtf8(path), FSC_PRIORITY_BASE);
_sdCard01Mounted = true;
}
@ -142,7 +142,7 @@ namespace coreinit
std::error_code ec;
const auto path = ActiveSettings::GetPath("sdcard/");
fs::create_directories(path, ec);
if (!FSCDeviceHostFS_Mount(mountPathOut, _utf8Wrapper(path), FSC_PRIORITY_BASE))
if (!FSCDeviceHostFS_Mount(mountPathOut, _pathToUtf8(path), FSC_PRIORITY_BASE))
return FS_RESULT::ERR_PLACEHOLDER;
_sdCard01Mounted = true;
}
@ -150,7 +150,7 @@ namespace coreinit
if (_mlc01Mounted)
return FS_RESULT::ERR_PLACEHOLDER;
if (!FSCDeviceHostFS_Mount(mountPathOut, _utf8Wrapper(ActiveSettings::GetMlcPath()), FSC_PRIORITY_BASE))
if (!FSCDeviceHostFS_Mount(mountPathOut, _pathToUtf8(ActiveSettings::GetMlcPath()), FSC_PRIORITY_BASE))
return FS_RESULT::ERR_PLACEHOLDER;
_mlc01Mounted = true;
}

View file

@ -51,7 +51,7 @@ namespace acp
// mount save path
const auto mlc = ActiveSettings::GetMlcPath("usr/save/{:08x}/{:08x}/user/", high, low);
FSCDeviceHostFS_Mount("/vol/save/", _utf8Wrapper(mlc), FSC_PRIORITY_BASE);
FSCDeviceHostFS_Mount("/vol/save/", _pathToUtf8(mlc), FSC_PRIORITY_BASE);
nnResult mountResult = BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_ACP, 0);
return _ACPConvertResultToACPStatus(&mountResult, "ACPMountSaveDir", 0x60);
}

View file

@ -66,7 +66,7 @@ void CafeSaveList::RefreshThreadWorker()
{
if(!it_titleHigh.is_directory(ec))
continue;
std::string dirName = _utf8Wrapper(it_titleHigh.path().filename());
std::string dirName = _pathToUtf8(it_titleHigh.path().filename());
if(dirName.empty())
continue;
uint32 titleIdHigh;
@ -78,7 +78,7 @@ void CafeSaveList::RefreshThreadWorker()
{
if (!it_titleLow.is_directory(ec))
continue;
dirName = _utf8Wrapper(it_titleLow.path().filename());
dirName = _pathToUtf8(it_titleLow.path().filename());
if (dirName.empty())
continue;
uint32 titleIdLow;

View file

@ -177,12 +177,12 @@ bool TitleInfo::DetectFormat(const fs::path& path, fs::path& pathOut, TitleDataF
std::error_code ec;
if (path.has_extension() && fs::is_regular_file(path, ec))
{
std::string filenameStr = _utf8Wrapper(path.filename());
std::string filenameStr = _pathToUtf8(path.filename());
if (boost::iends_with(filenameStr, ".rpx"))
{
// is in code folder?
fs::path parentPath = path.parent_path();
if (boost::iequals(_utf8Wrapper(parentPath.filename()), "code"))
if (boost::iequals(_pathToUtf8(parentPath.filename()), "code"))
{
parentPath = parentPath.parent_path();
// next to content and meta?
@ -370,7 +370,7 @@ bool TitleInfo::Mount(std::string_view virtualPath, std::string_view subfolder,
{
fs::path hostFSPath = m_fullPath;
hostFSPath.append(subfolder);
bool r = FSCDeviceHostFS_Mount(std::string(virtualPath).c_str(), _utf8Wrapper(hostFSPath), mountPriority);
bool r = FSCDeviceHostFS_Mount(std::string(virtualPath).c_str(), _pathToUtf8(hostFSPath), mountPriority);
cemu_assert_debug(r);
if (!r)
{
@ -495,7 +495,7 @@ bool TitleInfo::ParseXmlInfo()
if (!m_parsedMetaXml || !m_parsedAppXml || !m_parsedCosXml)
{
if (hasAnyXml)
cemuLog_log(LogType::Force, "Title has missing meta .xml files. Title path: {}", _utf8Wrapper(m_fullPath));
cemuLog_log(LogType::Force, "Title has missing meta .xml files. Title path: {}", _pathToUtf8(m_fullPath));
delete m_parsedMetaXml;
delete m_parsedAppXml;
delete m_parsedCosXml;
@ -621,7 +621,7 @@ std::string TitleInfo::GetPrintPath() const
if (!m_isValid)
return "invalid";
std::string tmp;
tmp.append(_utf8Wrapper(m_fullPath));
tmp.append(_pathToUtf8(m_fullPath));
switch (m_titleFormat)
{
case TitleDataFormat::HOST_FS:

View file

@ -120,16 +120,16 @@ void CafeTitleList::StoreCacheFile()
titleInfoNode.append_child("region").append_child(pugi::node_pcdata).set_value(fmt::format("{}", (uint32)info.region).c_str());
titleInfoNode.append_child("name").append_child(pugi::node_pcdata).set_value(info.titleName.c_str());
titleInfoNode.append_child("format").append_child(pugi::node_pcdata).set_value(fmt::format("{}", (uint32)info.titleDataFormat).c_str());
titleInfoNode.append_child("path").append_child(pugi::node_pcdata).set_value(_utf8Wrapper(info.path).c_str());
titleInfoNode.append_child("path").append_child(pugi::node_pcdata).set_value(_pathToUtf8(info.path).c_str());
if(!info.subPath.empty())
titleInfoNode.append_child("sub_path").append_child(pugi::node_pcdata).set_value(_utf8Wrapper(info.subPath).c_str());
titleInfoNode.append_child("sub_path").append_child(pugi::node_pcdata).set_value(_pathToUtf8(info.subPath).c_str());
}
fs::path tmpPath = fs::path(sTLCacheFilePath.parent_path()).append(fmt::format("{}__tmp", _utf8Wrapper(sTLCacheFilePath.filename())));
fs::path tmpPath = fs::path(sTLCacheFilePath.parent_path()).append(fmt::format("{}__tmp", _pathToUtf8(sTLCacheFilePath.filename())));
std::ofstream fileOut(tmpPath, std::ios::out | std::ios::binary | std::ios::trunc);
if (!fileOut.is_open())
{
cemuLog_log(LogType::Force, "Unable to store title list in {}", _utf8Wrapper(tmpPath));
cemuLog_log(LogType::Force, "Unable to store title list in {}", _pathToUtf8(tmpPath));
return;
}
doc.save(fileOut, " ", 1, pugi::xml_encoding::encoding_utf8);
@ -158,7 +158,7 @@ void CafeTitleList::SetMLCPath(fs::path path)
std::error_code ec;
if (!fs::is_directory(path, ec))
{
cemuLog_log(LogType::Force, "MLC set to invalid path: {}", _utf8Wrapper(path));
cemuLog_log(LogType::Force, "MLC set to invalid path: {}", _pathToUtf8(path));
return;
}
sTLMLCPath = path;
@ -211,12 +211,12 @@ void _RemoveTitleFromMultimap(TitleInfo* titleInfo)
// in the special case that path points to a WUA file, all contained titles will be added
void CafeTitleList::AddTitleFromPath(fs::path path)
{
if (path.has_extension() && boost::iequals(_utf8Wrapper(path.extension()), ".wua"))
if (path.has_extension() && boost::iequals(_pathToUtf8(path.extension()), ".wua"))
{
ZArchiveReader* zar = ZArchiveReader::OpenFromFile(path);
if (!zar)
{
cemuLog_log(LogType::Force, "Found {} but it is not a valid Wii U archive file", _utf8Wrapper(path));
cemuLog_log(LogType::Force, "Found {} but it is not a valid Wii U archive file", _pathToUtf8(path));
return;
}
// enumerate all contained titles
@ -233,7 +233,7 @@ void CafeTitleList::AddTitleFromPath(fs::path path)
uint16 parsedVersion;
if (!TitleInfo::ParseWuaTitleFolderName(dirEntry.name, parsedId, parsedVersion))
{
cemuLog_log(LogType::Force, "Invalid title directory in {}: \"{}\"", _utf8Wrapper(path), dirEntry.name);
cemuLog_log(LogType::Force, "Invalid title directory in {}: \"{}\"", _pathToUtf8(path), dirEntry.name);
continue;
}
// valid subdirectory
@ -351,7 +351,7 @@ void CafeTitleList::ScanGamePath(const fs::path& path)
{
dirsInDirectory.emplace_back(it.path());
std::string dirName = _utf8Wrapper(it.path().filename());
std::string dirName = _pathToUtf8(it.path().filename());
if (boost::iequals(dirName, "content"))
hasContentFolder = true;
else if (boost::iequals(dirName, "code"))
@ -366,7 +366,7 @@ void CafeTitleList::ScanGamePath(const fs::path& path)
// since checking files is slow, we only do it for known file extensions
if (!it.has_extension())
continue;
if (!_IsKnownFileExtension(_utf8Wrapper(it.extension())))
if (!_IsKnownFileExtension(_pathToUtf8(it.extension())))
continue;
AddTitleFromPath(it);
}
@ -384,7 +384,7 @@ void CafeTitleList::ScanGamePath(const fs::path& path)
{
for (auto& it : dirsInDirectory)
{
std::string dirName = _utf8Wrapper(it.filename());
std::string dirName = _pathToUtf8(it.filename());
if (!boost::iequals(dirName, "content") &&
!boost::iequals(dirName, "code") &&
!boost::iequals(dirName, "meta"))
@ -408,7 +408,7 @@ void CafeTitleList::ScanMLCPath(const fs::path& path)
if (!it.is_directory())
continue;
// only scan directories which match the title id naming scheme
std::string dirName = _utf8Wrapper(it.path().filename());
std::string dirName = _pathToUtf8(it.path().filename());
if(dirName.size() != 8)
continue;
bool containsNoHexCharacter = false;