mirror of
https://github.com/wiiu-env/RPXLoadingModule.git
synced 2024-11-22 01:49:15 +01:00
Add the shortname to the save directory of a wuhb
This commit is contained in:
parent
ba1ea768e4
commit
7ffde9961b
@ -91,14 +91,19 @@ WUMS_APPLICATION_STARTS() {
|
||||
if (_SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY) == OSGetTitleID() &&
|
||||
strlen(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath) > 0) {
|
||||
uint32_t currentHash = StringTools::hash(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath);
|
||||
std::string shortNameSanitized = sanitizeName(gReplacementInfo.rpxReplacementInfo.metaInformation.shortname);
|
||||
|
||||
nn::act::Initialize();
|
||||
nn::act::PersistentId persistentId = nn::act::GetPersistentId();
|
||||
nn::act::Finalize();
|
||||
|
||||
std::string basePath = string_format("fs:/vol/external01/wiiu/apps/save/%08X", currentHash);
|
||||
std::string common = string_format("fs:/vol/external01/wiiu/apps/save/%08X/common", currentHash);
|
||||
std::string user = string_format("fs:/vol/external01/wiiu/apps/save/%08X/%08X", currentHash, 0x80000000 | persistentId);
|
||||
if (!shortNameSanitized.empty()) {
|
||||
basePath += string_format(" (%s)", shortNameSanitized.c_str());
|
||||
}
|
||||
|
||||
std::string common = basePath + "/common";
|
||||
std::string user = basePath + string_format("/%08X", 0x80000000 | persistentId);
|
||||
|
||||
CreateSubfolder(common.c_str());
|
||||
CreateSubfolder(user.c_str());
|
||||
|
@ -1,9 +1,41 @@
|
||||
#include "utils/logger.h"
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <whb/log.h>
|
||||
|
||||
#define PRINTF_BUFFER_LENGTH 2048
|
||||
std::string sanitizeName(const std::string &input) {
|
||||
if (input.empty() || input.starts_with(' ')) {
|
||||
return "";
|
||||
}
|
||||
std::string result = input;
|
||||
std::string illegalChars = "\\/:?\"<>|@=;`_^][";
|
||||
for (auto it = result.begin(); it < result.end(); ++it) {
|
||||
if (*it < '0' || *it > 'z') {
|
||||
*it = ' ';
|
||||
}
|
||||
}
|
||||
for (auto it = result.begin(); it < result.end(); ++it) {
|
||||
bool found = illegalChars.find(*it) != std::string::npos;
|
||||
if (found) {
|
||||
*it = ' ';
|
||||
}
|
||||
}
|
||||
uint32_t length = result.length();
|
||||
for (uint32_t i = 1; i < length; ++i) {
|
||||
if (result[i - 1] == ' ' && result[i] == ' ') {
|
||||
result.erase(i, 1);
|
||||
i--;
|
||||
length--;
|
||||
}
|
||||
}
|
||||
if (result.size() == 1 && result[0] == ' ') {
|
||||
result.clear();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#define PRINTF_BUFFER_LENGTH 2048
|
||||
// https://gist.github.com/ccbrown/9722406
|
||||
void dumpHex(const void *data, size_t size) {
|
||||
char ascii[17];
|
||||
|
@ -35,6 +35,8 @@ bool remove_locked_first_if(std::mutex &mutex, std::forward_list<T, Allocator> &
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string sanitizeName(const std::string &input);
|
||||
|
||||
// those work only in powers of 2
|
||||
#define ROUNDDOWN(val, align) ((val) & ~(align - 1))
|
||||
#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align - 1)), align)
|
Loading…
Reference in New Issue
Block a user