mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-07-05 09:02:15 +02:00
Awful (and not tested) Multi-User LFS support
This commit is contained in:
parent
c40bb9b317
commit
e42ca20734
@ -2,6 +2,7 @@
|
|||||||
#include <stratosphere.hpp>
|
#include <stratosphere.hpp>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <dirent.h>
|
||||||
|
|
||||||
#include "sm_mitm.h"
|
#include "sm_mitm.h"
|
||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
@ -83,11 +84,35 @@ Result Utils::OpenSdFileForAtmosphere(u64 title_id, const char *fn, int flags, F
|
|||||||
return 0xFA202;
|
return 0xFA202;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// multi-user stuff
|
||||||
|
// todo: add error handling (should i use fatalSimple?)
|
||||||
|
accountInitialize();
|
||||||
|
u128 user_id;
|
||||||
|
bool acc_selected;
|
||||||
|
accountGetActiveUser(&user_id, &acc_selected);
|
||||||
|
AccountProfile profile;
|
||||||
|
accountGetProfile(&profile, user_id);
|
||||||
|
AccountUserData user_data;
|
||||||
|
AccountProfileBase profile_base;
|
||||||
|
accountProfileGet(&profile, &user_data, &profile_base);
|
||||||
|
|
||||||
char path[FS_MAX_PATH];
|
char path[FS_MAX_PATH];
|
||||||
if (*fn == '/') {
|
if (*fn == '/') {
|
||||||
snprintf(path, sizeof(path), "/atmosphere/titles/%016lx%s", title_id, fn);
|
snprintf(path, sizeof(path), "sdmc:/atmosphere/titles/%016lx_%s", title_id, profile_base.username);
|
||||||
|
DIR* dir = opendir(path);
|
||||||
|
if (dir) {
|
||||||
|
snprintf(path, sizeof(path), "/atmosphere/titles/%016lx_$s%s", title_id, profile_base.username, fn);
|
||||||
|
} else {
|
||||||
|
snprintf(path, sizeof(path), "/atmosphere/titles/%016lx%s", title_id, fn);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
snprintf(path, sizeof(path), "/atmosphere/titles/%016lx/%s", title_id, fn);
|
snprintf(path, sizeof(path), "sdmc:/atmosphere/titles/%016lx_%s", title_id, profile_base.username);
|
||||||
|
DIR* dir = opendir(path);
|
||||||
|
if (dir) {
|
||||||
|
snprintf(path, sizeof(path), "/atmosphere/titles/%016lx_$s/%s", title_id, profile_base.username, fn);
|
||||||
|
} else {
|
||||||
|
snprintf(path, sizeof(path), "/atmosphere/titles/%016lx/%s", title_id, fn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return fsFsOpenFile(&g_sd_filesystem, path, flags, out);
|
return fsFsOpenFile(&g_sd_filesystem, path, flags, out);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user