mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-29 04:24:17 +01:00
FSC: Use utf8 for mounting and internal target path
This commit is contained in:
parent
cf598e38c1
commit
0e0602e8d9
@ -626,7 +626,7 @@ namespace CafeSystem
|
||||
if (fs::is_directory(contentPath, ec))
|
||||
{
|
||||
// mounting content folder
|
||||
bool r = FSCDeviceHostFS_Mount(std::string("/vol/content").c_str(), boost::nowide::widen(_utf8Wrapper(contentPath)).c_str(), FSC_PRIORITY_BASE);
|
||||
bool r = FSCDeviceHostFS_Mount(std::string("/vol/content").c_str(), _utf8Wrapper(contentPath), FSC_PRIORITY_BASE);
|
||||
if (!r)
|
||||
{
|
||||
cemuLog_log(LogType::Force, "Failed to mount {}", _utf8Wrapper(contentPath).c_str());
|
||||
@ -635,7 +635,7 @@ namespace CafeSystem
|
||||
}
|
||||
}
|
||||
// mount code folder to a virtual temporary path
|
||||
FSCDeviceHostFS_Mount(std::string("/internal/code/").c_str(), boost::nowide::widen(_utf8Wrapper(executablePath.parent_path())).c_str(), FSC_PRIORITY_BASE);
|
||||
FSCDeviceHostFS_Mount(std::string("/internal/code/").c_str(), _utf8Wrapper(executablePath.parent_path()), FSC_PRIORITY_BASE);
|
||||
std::string internalExecutablePath = "/internal/code/";
|
||||
internalExecutablePath.append(_utf8Wrapper(executablePath.filename()));
|
||||
_pathToExecutable = internalExecutablePath;
|
||||
|
@ -5,10 +5,10 @@ struct FSCMountPathNode
|
||||
std::string path;
|
||||
std::vector<FSCMountPathNode*> subnodes;
|
||||
FSCMountPathNode* parent;
|
||||
// device target and path (if list_subnodes is nullptr)
|
||||
// device target and path (if subnodes is empty)
|
||||
fscDeviceC* device{ nullptr };
|
||||
void* ctx{ nullptr };
|
||||
std::wstring targetPath;
|
||||
std::string deviceTargetPath; // the destination base path for the device, utf8
|
||||
// priority
|
||||
sint32 priority{};
|
||||
|
||||
@ -119,42 +119,44 @@ FSCMountPathNode* fsc_createMountPath(CoreinitFSParsedPath* parsedMountPath, sin
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Map a virtual FSC directory to a device and device directory
|
||||
sint32 fsc_mount(const char* mountPath, const wchar_t* _targetPath, fscDeviceC* fscDevice, void* ctx, sint32 priority)
|
||||
// Map a virtual FSC directory to a device. targetPath points to the destination base directory within the device
|
||||
sint32 fsc_mount(std::string_view mountPath, std::string_view targetPath, fscDeviceC* fscDevice, void* ctx, sint32 priority)
|
||||
{
|
||||
cemu_assert(fscDevice); // device must not be nullptr
|
||||
cemu_assert(fscDevice);
|
||||
std::string mountPathTmp(mountPath);
|
||||
// make sure the target path ends with a slash
|
||||
std::wstring targetPath(_targetPath);
|
||||
if (!targetPath.empty() && (targetPath.back() != '/' && targetPath.back() != '\\'))
|
||||
targetPath.push_back('/');
|
||||
std::string targetPathWithSlash(targetPath);
|
||||
if (!targetPathWithSlash.empty() && (targetPathWithSlash.back() != '/' && targetPathWithSlash.back() != '\\'))
|
||||
targetPathWithSlash.push_back('/');
|
||||
|
||||
// parse mount path
|
||||
CoreinitFSParsedPath parsedMountPath;
|
||||
coreinitFS_parsePath(&parsedMountPath, mountPath);
|
||||
coreinitFS_parsePath(&parsedMountPath, mountPathTmp.c_str());
|
||||
// register path
|
||||
fscEnter();
|
||||
FSCMountPathNode* node = fsc_createMountPath(&parsedMountPath, priority);
|
||||
if( !node )
|
||||
{
|
||||
// path empty, invalid or already used
|
||||
cemuLog_log(LogType::Force, "fsc_mount failed (virtual path: %s)", mountPath);
|
||||
cemuLog_log(LogType::Force, "fsc_mount failed (virtual path: {})", mountPath);
|
||||
fscLeave();
|
||||
return FSC_STATUS_INVALID_PATH;
|
||||
}
|
||||
node->device = fscDevice;
|
||||
node->ctx = ctx;
|
||||
node->targetPath = targetPath;
|
||||
node->deviceTargetPath = targetPathWithSlash;
|
||||
fscLeave();
|
||||
return FSC_STATUS_OK;
|
||||
}
|
||||
|
||||
bool fsc_unmount(const char* mountPath, sint32 priority)
|
||||
bool fsc_unmount(std::string_view mountPath, sint32 priority)
|
||||
{
|
||||
std::string _tmp(mountPath);
|
||||
CoreinitFSParsedPath parsedMountPath;
|
||||
coreinitFS_parsePath(&parsedMountPath, mountPath);
|
||||
coreinitFS_parsePath(&parsedMountPath, _tmp.c_str());
|
||||
|
||||
fscEnter();
|
||||
FSCMountPathNode* mountPathNode = fsc_lookupPathVirtualNode(mountPath, priority);
|
||||
FSCMountPathNode* mountPathNode = fsc_lookupPathVirtualNode(_tmp.c_str(), priority);
|
||||
if (!mountPathNode)
|
||||
{
|
||||
fscLeave();
|
||||
@ -218,7 +220,7 @@ bool fsc_lookupPath(const char* path, std::wstring& devicePathOut, fscDeviceC**
|
||||
{
|
||||
if (nodeParent->device)
|
||||
{
|
||||
devicePathOut = nodeParent->targetPath;
|
||||
devicePathOut = boost::nowide::widen(nodeParent->deviceTargetPath);
|
||||
for (sint32 f = i; f < parsedPath.numNodes; f++)
|
||||
{
|
||||
const char* nodeName = coreinitFS_getNodeName(&parsedPath, f);
|
||||
|
@ -161,8 +161,8 @@ struct FSCVirtualFile
|
||||
#define FSC_PRIORITY_COUNT (4)
|
||||
|
||||
void fsc_init();
|
||||
sint32 fsc_mount(const char* mountPath, const wchar_t* targetPath, fscDeviceC* fscDevice, void* ctx, sint32 priority=0);
|
||||
bool fsc_unmount(const char* mountPath, sint32 priority);
|
||||
sint32 fsc_mount(std::string_view mountPath, std::string_view targetPath, fscDeviceC* fscDevice, void* ctx, sint32 priority=0);
|
||||
bool fsc_unmount(std::string_view mountPath, sint32 priority);
|
||||
void fsc_unmountAll();
|
||||
|
||||
FSCVirtualFile* fsc_open(const char* path, FSC_ACCESS_FLAG accessFlags, sint32* fscStatus, sint32 maxPriority=FSC_PRIORITY_MAX);
|
||||
@ -188,14 +188,14 @@ bool fsc_doesFileExist(const char* path, sint32 maxPriority = FSC_PRIORITY_MAX);
|
||||
bool fsc_doesDirectoryExist(const char* path, sint32 maxPriority = FSC_PRIORITY_MAX);
|
||||
|
||||
// wud device
|
||||
bool FSCDeviceWUD_Mount(const char* mountPath, std::string_view destinationBaseDir, class FSTVolume* mountedVolume, sint32 priority);
|
||||
bool FSCDeviceWUD_Mount(std::string_view mountPath, std::string_view destinationBaseDir, class FSTVolume* mountedVolume, sint32 priority);
|
||||
|
||||
// wua device
|
||||
bool FSCDeviceWUA_Mount(const char* mountPath, std::string_view destinationBaseDir, class ZArchiveReader* archive, sint32 priority);
|
||||
bool FSCDeviceWUA_Mount(std::string_view mountPath, std::string_view destinationBaseDir, class ZArchiveReader* archive, sint32 priority);
|
||||
|
||||
// hostFS device
|
||||
void fscDeviceHostFS_mapBaseDirectories_deprecated();
|
||||
bool FSCDeviceHostFS_Mount(const char* mountPath, const wchar_t* hostFSPath, sint32 priority);
|
||||
bool FSCDeviceHostFS_Mount(std::string_view mountPath, std::string_view hostTargetPath, sint32 priority);
|
||||
|
||||
// redirect device
|
||||
void fscDeviceRedirect_map();
|
||||
|
@ -293,14 +293,11 @@ public:
|
||||
void fscDeviceHostFS_mapBaseDirectories_deprecated()
|
||||
{
|
||||
const auto mlc = ActiveSettings::GetMlcPath();
|
||||
fsc_mount("/cemuBossStorage/", (mlc / "usr/boss/").generic_wstring().c_str(), &fscDeviceHostFSC::instance(), NULL, FSC_PRIORITY_BASE);
|
||||
fsc_mount("/vol/storage_mlc01/", (mlc / "").generic_wstring().c_str(), &fscDeviceHostFSC::instance(), NULL, FSC_PRIORITY_BASE);
|
||||
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);
|
||||
}
|
||||
|
||||
bool FSCDeviceHostFS_Mount(const char* mountPath, const wchar_t* hostFSPath, sint32 priority)
|
||||
bool FSCDeviceHostFS_Mount(std::string_view mountPath, std::string_view hostTargetPath, sint32 priority)
|
||||
{
|
||||
std::wstring hostTargetPath(hostFSPath);
|
||||
if (!hostTargetPath.empty() && (hostTargetPath.back() != '/' && hostTargetPath.back() != '\\'))
|
||||
hostTargetPath.push_back('/');
|
||||
return fsc_mount(mountPath, hostTargetPath.c_str(), &fscDeviceHostFSC::instance(), nullptr, priority) == FSC_STATUS_OK;
|
||||
return fsc_mount(mountPath, hostTargetPath, &fscDeviceHostFSC::instance(), nullptr, priority) == FSC_STATUS_OK;
|
||||
}
|
@ -52,6 +52,6 @@ void fscDeviceRedirect_map()
|
||||
{
|
||||
if (_redirectMapped)
|
||||
return;
|
||||
fsc_mount("/", L"/", &fscDeviceTypeRedirect::instance(), nullptr, FSC_PRIORITY_REDIRECT);
|
||||
fsc_mount("/", "/", &fscDeviceTypeRedirect::instance(), nullptr, FSC_PRIORITY_REDIRECT);
|
||||
_redirectMapped = true;
|
||||
}
|
||||
|
@ -169,10 +169,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
bool FSCDeviceWUA_Mount(const char* mountPath, std::string_view destinationBaseDir, ZArchiveReader* archive, sint32 priority)
|
||||
bool FSCDeviceWUA_Mount(std::string_view mountPath, std::string_view destinationBaseDir, ZArchiveReader* archive, sint32 priority)
|
||||
{
|
||||
std::wstring hostTargetPath(boost::nowide::widen(destinationBaseDir.data(), destinationBaseDir.size()));
|
||||
if (!hostTargetPath.empty() && (hostTargetPath.back() != '/' && hostTargetPath.back() != '\\'))
|
||||
hostTargetPath.push_back('/');
|
||||
return fsc_mount(mountPath, hostTargetPath.c_str(), &fscDeviceWUAC::instance(), archive, priority) == FSC_STATUS_OK;
|
||||
return fsc_mount(mountPath, destinationBaseDir, &fscDeviceWUAC::instance(), archive, priority) == FSC_STATUS_OK;
|
||||
}
|
@ -157,10 +157,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
bool FSCDeviceWUD_Mount(const char* mountPath, std::string_view destinationBaseDir, FSTVolume* mountedVolume, sint32 priority)
|
||||
bool FSCDeviceWUD_Mount(std::string_view mountPath, std::string_view destinationBaseDir, FSTVolume* mountedVolume, sint32 priority)
|
||||
{
|
||||
std::wstring hostTargetPath(boost::nowide::widen(destinationBaseDir.data(), destinationBaseDir.size()));
|
||||
if (!hostTargetPath.empty() && (hostTargetPath.back() != '/' && hostTargetPath.back() != '\\'))
|
||||
hostTargetPath.push_back('/');
|
||||
return fsc_mount(mountPath, hostTargetPath.c_str(), &fscDeviceWUDC::instance(), mountedVolume, priority) == FSC_STATUS_OK;
|
||||
return fsc_mount(mountPath, destinationBaseDir, &fscDeviceWUDC::instance(), mountedVolume, priority) == FSC_STATUS_OK;
|
||||
}
|
@ -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", path.generic_wstring().c_str() , FSC_PRIORITY_BASE);
|
||||
FSCDeviceHostFS_Mount("/vol/external01", _utf8Wrapper(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, path.generic_wstring().c_str(), FSC_PRIORITY_BASE))
|
||||
if (!FSCDeviceHostFS_Mount(mountPathOut, _utf8Wrapper(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, ActiveSettings::GetMlcPath().generic_wstring().c_str(), FSC_PRIORITY_BASE))
|
||||
if (!FSCDeviceHostFS_Mount(mountPathOut, _utf8Wrapper(ActiveSettings::GetMlcPath()), FSC_PRIORITY_BASE))
|
||||
return FS_RESULT::ERR_PLACEHOLDER;
|
||||
_mlc01Mounted = true;
|
||||
}
|
||||
|
@ -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/", mlc.generic_wstring().c_str(), FSC_PRIORITY_BASE);
|
||||
FSCDeviceHostFS_Mount("/vol/save/", _utf8Wrapper(mlc), FSC_PRIORITY_BASE);
|
||||
nnResult mountResult = BUILD_NN_RESULT(NN_RESULT_LEVEL_SUCCESS, NN_RESULT_MODULE_NN_ACP, 0);
|
||||
return _ACPConvertResultToACPStatus(&mountResult, "ACPMountSaveDir", 0x60);
|
||||
}
|
||||
|
@ -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(), boost::nowide::widen(_utf8Wrapper(hostFSPath)).c_str(), mountPriority);
|
||||
bool r = FSCDeviceHostFS_Mount(std::string(virtualPath).c_str(), _utf8Wrapper(hostFSPath), mountPriority);
|
||||
cemu_assert_debug(r);
|
||||
if (!r)
|
||||
{
|
||||
@ -387,7 +387,7 @@ bool TitleInfo::Mount(std::string_view virtualPath, std::string_view subfolder,
|
||||
}
|
||||
if (!m_wudVolume)
|
||||
return false;
|
||||
bool r = FSCDeviceWUD_Mount(std::string(virtualPath).c_str(), subfolder, m_wudVolume, mountPriority);
|
||||
bool r = FSCDeviceWUD_Mount(virtualPath, subfolder, m_wudVolume, mountPriority);
|
||||
cemu_assert_debug(r);
|
||||
if (!r)
|
||||
{
|
||||
@ -404,7 +404,7 @@ bool TitleInfo::Mount(std::string_view virtualPath, std::string_view subfolder,
|
||||
if (!m_zarchive)
|
||||
return false;
|
||||
}
|
||||
bool r = FSCDeviceWUA_Mount(std::string(virtualPath).c_str(), std::string(m_subPath).append("/").append(subfolder), m_zarchive, mountPriority);
|
||||
bool r = FSCDeviceWUA_Mount(virtualPath, std::string(m_subPath).append("/").append(subfolder), m_zarchive, mountPriority);
|
||||
if (!r)
|
||||
{
|
||||
cemuLog_log(LogType::Force, "Failed to mount {} to {}", virtualPath, subfolder);
|
||||
|
Loading…
Reference in New Issue
Block a user