From 702524251e80b899a28a94c86599693e1f496617 Mon Sep 17 00:00:00 2001 From: Maschell Date: Mon, 5 Apr 2021 21:32:40 +0200 Subject: [PATCH] Add support for redirecting the /vol/content folder --- src/FSWrapper.cpp | 6 ++++-- src/RPXLoading.cpp | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/FSWrapper.cpp b/src/FSWrapper.cpp index 40a9f6d..ec8d3c3 100644 --- a/src/FSWrapper.cpp +++ b/src/FSWrapper.cpp @@ -36,6 +36,9 @@ inline void getFullPath(char *pathForCheck, int pathSize, char *path) { } inline bool checkForSave(char *pathForCheck, int pathSize, char *path) { + if (!gReplacementInfo.contentReplacementInfo.replaceSave) { + return false; + } if (strncmp(path, "/vol/save", 9) == 0) { int copyLen = strlen(path); char copy[copyLen + 1]; @@ -468,8 +471,7 @@ FSStatus FSGetStatWrapper(char *path, FSStat *stats, FSErrorFlag errorMask, getFullPath(pathForCheck, sizeof(pathForCheck), path); - if (gReplacementInfo.contentReplacementInfo.replaceSave && - checkForSave(pathForCheck, sizeof(pathForCheck), pathForCheck)) { + if (checkForSave(pathForCheck, sizeof(pathForCheck), pathForCheck)) { DEBUG_FUNCTION_LINE("Redirect save to %s", pathForCheck); return fallback_function(pathForCheck); } diff --git a/src/RPXLoading.cpp b/src/RPXLoading.cpp index d9ecacc..6c65ab3 100644 --- a/src/RPXLoading.cpp +++ b/src/RPXLoading.cpp @@ -280,10 +280,26 @@ bool RL_FileExists(const char *name) { return CheckFile(name) || CheckFile(checkgz.c_str()); } +bool RL_RedirectContentWithFallback(const char * newContentPath) { + auto dirHandle = opendir(newContentPath); + if (dirHandle == nullptr) { + return false; + } + closedir(dirHandle); + + gReplacementInfo.contentReplacementInfo.replacementPath[0] = '\0'; + strncat(gReplacementInfo.contentReplacementInfo.replacementPath, newContentPath, sizeof(gReplacementInfo.contentReplacementInfo.replacementPath) - 1); + gReplacementInfo.contentReplacementInfo.mode = CONTENTREDIRECT_FROM_PATH; + gReplacementInfo.contentReplacementInfo.fallbackOnError = true; + gReplacementInfo.contentReplacementInfo.replaceSave = false; + return true; +} + WUMS_EXPORT_FUNCTION(RL_LoadFromSDOnNextLaunch); WUMS_EXPORT_FUNCTION(RL_MountBundle); WUMS_EXPORT_FUNCTION(RL_UnmountBundle); WUMS_EXPORT_FUNCTION(RL_FileOpen); WUMS_EXPORT_FUNCTION(RL_FileRead); WUMS_EXPORT_FUNCTION(RL_FileClose); -WUMS_EXPORT_FUNCTION(RL_FileExists); \ No newline at end of file +WUMS_EXPORT_FUNCTION(RL_FileExists); +WUMS_EXPORT_FUNCTION(RL_RedirectContentWithFallback); \ No newline at end of file