Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch: have savefiles specific to each user #2

Merged
merged 4 commits into from
Jun 6, 2019
Merged

switch: have savefiles specific to each user #2

merged 4 commits into from
Jun 6, 2019

Conversation

terabyte25
Copy link

Like skyrim.

(I haven't even tested out or compiled these changes, so they are probably horribly unsafe and won't compile)

@fgsfdsfgs
Copy link
Owner

fgsfdsfgs commented Jun 6, 2019

Maybe move accountInitialize and accountExit to userAppInit/userAppExit? The rest should probably be done in Switch::startup or something in that case. Or just move the entire thing to startup.
Additionally, you're assigning C strings (which would work if the variable was a char *).

@terabyte25
Copy link
Author

terabyte25 commented Jun 6, 2019

Yeah, I figure I'll just move the whole thing with usernames to startup.

For the c strings, I guess I'll just make username a c++ string then to assign the profile username I'll just do

username = std::string(profilebase.username);

(I'm not very proficient with how c does strings, I just use c++'s strings most of the time)

@terabyte25
Copy link
Author

Should be good now.

@fgsfdsfgs
Copy link
Owner

Builds now.

@fgsfdsfgs fgsfdsfgs merged commit a0da39b into fgsfdsfgs:master Jun 6, 2019
@terabyte25
Copy link
Author

terabyte25 commented Jun 6, 2019

Probably doesn't really work because I didn't do the RC checks (like in the example) and what not.

@fgsfdsfgs
Copy link
Owner

It works, although I'm going to change it a little bit.

@fgsfdsfgs
Copy link
Owner

Now that I think about it, it could be a bad idea because usernames can contain UTF-8 and I have no idea if that's handled correctly in the fs driver.

@terabyte25
Copy link
Author

I think boost has built in support for UTF8?

@fgsfdsfgs
Copy link
Owner

fgsfdsfgs commented Jun 6, 2019

Boost might, however fs and other things might not.
I have checked, names containing Unicode characters make it silently die when it tries to create the folder.
FAT32 also doesn't support UTF-8 directly, IIRC Microsoft uses some wacky workarounds for that, but we have a different fs driver.

@terabyte25
Copy link
Author

@terabyte25
Copy link
Author

Does libnx's functions return it in utf8?

@fgsfdsfgs
Copy link
Owner

fgsfdsfgs commented Jun 6, 2019

Yes. I have obtained the error message it crashes with and it seems to indicate that mkdir or the underlying fs call cannot create a path that has unicode in it, because it attempts to create the directory and right after that I get

Error: boost::filesystem::create_directory: No such file or directory: "./data/いしにさ"

@fgsfdsfgs
Copy link
Owner

fgsfdsfgs commented Jun 6, 2019

It's actually possible to create a folder with Cyrillic in the name, but not Japanese. Wonder why.
UPD: Thought that this had to do with system locale or something, but changing the region to Japanese doesn't fix it. I think I'll revert it for the time being, if you have no other suggestions.

@terabyte25
Copy link
Author

For now I think a band-aid fix would be to detect if the username is non ASCII, and if it is just use the fall back.

@terabyte25
Copy link
Author

terabyte25 commented Jun 6, 2019

Maybe you might get a result with messing around with the locales?

std::local loc=boost::locale::generator().generate(""); 

std::locale::global(loc);

boost::filesystem::path::imbue(std::locale()); 

@fgsfdsfgs
Copy link
Owner

Nah, it seems to be a bug with fs. It just doesn't deal with certain character ranges apparently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants