mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-04 14:01:17 +12:00
FSC: Refactor FileTree and remove redundant path parser class
This commit is contained in:
parent
b8462cec8b
commit
1ce629126a
3 changed files with 61 additions and 245 deletions
|
@ -9,23 +9,22 @@ struct RedirectEntry
|
|||
sint32 priority;
|
||||
};
|
||||
|
||||
FileTree<RedirectEntry, false> redirectTree;
|
||||
FSAFileTree<RedirectEntry> redirectTree;
|
||||
|
||||
void fscDeviceRedirect_add(std::string_view virtualSourcePath, const fs::path& targetFilePath, sint32 priority)
|
||||
{
|
||||
std::wstring virtualSourcePathW = boost::nowide::widen(std::string(virtualSourcePath));
|
||||
// check if source already has a redirection
|
||||
RedirectEntry* existingEntry;
|
||||
if (redirectTree.getFile(virtualSourcePathW, existingEntry))
|
||||
if (redirectTree.getFile(virtualSourcePath, existingEntry))
|
||||
{
|
||||
if (existingEntry->priority >= priority)
|
||||
return; // dont replace entries with equal or higher priority
|
||||
// unregister existing entry
|
||||
redirectTree.removeFile(virtualSourcePathW.c_str());
|
||||
redirectTree.removeFile(virtualSourcePath);
|
||||
delete existingEntry;
|
||||
}
|
||||
RedirectEntry* entry = new RedirectEntry(targetFilePath, priority);
|
||||
redirectTree.addFile(virtualSourcePathW.c_str(), entry);
|
||||
redirectTree.addFile(virtualSourcePath, entry);
|
||||
}
|
||||
|
||||
class fscDeviceTypeRedirect : public fscDeviceC
|
||||
|
@ -33,7 +32,8 @@ class fscDeviceTypeRedirect : public fscDeviceC
|
|||
FSCVirtualFile* fscDeviceOpenByPath(std::wstring_view pathW, FSC_ACCESS_FLAG accessFlags, void* ctx, sint32* fscStatus) override
|
||||
{
|
||||
RedirectEntry* redirectionEntry;
|
||||
if (redirectTree.getFile(pathW, redirectionEntry))
|
||||
std::string pathTmp = boost::nowide::narrow(pathW);
|
||||
if (redirectTree.getFile(pathTmp, redirectionEntry))
|
||||
return FSCVirtualFile_Host::OpenFile(redirectionEntry->dstPath, accessFlags, *fscStatus);
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue