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

Ensure user paths are stored in a consistent manner. #10241

Merged
merged 4 commits into from Jan 1, 2022

Conversation

AdmiralCurtiss
Copy link
Contributor

That is:

  • All path separators are forward slashes.
  • Directory paths end with a separator.
  • File paths do not end with a separator.

@AdmiralCurtiss AdmiralCurtiss force-pushed the user-dir-consistency branch 2 times, most recently from 4cab2e4 to 6613492 Compare November 22, 2021 02:40
@MayImilae
Copy link
Contributor

What happens if the user enters a path incorrectly, say using backslash instead of forwardslash? What is the experience that the user will get when that occurs? Does it just fix it for them or will it alert them?

Also, isn't backslash \ used for paths on windows? I guess this isn't accounting for OS differences like that?

@AdmiralCurtiss
Copy link
Contributor Author

AdmiralCurtiss commented Nov 22, 2021

We've already been using / as the path separator on all platforms before this (see eg. here or here or here or anywhere we concatenate paths really; Windows does allow this!), this just makes it more explicit and something you can actually rely on.

If the user enters a backslash on Windows it will just get silently replaced with a forward slash internally.

@@ -34,10 +34,9 @@ void NANDImporter::ImportNANDBin(const std::string& path_to_bin,
if (!ReadNANDBin(path_to_bin, get_otp_dump_path))
return;

const std::string nand_root = File::GetUserPath(D_WIIROOT_IDX);
std::string nand_root = File::GetUserPath(D_WIIROOT_IDX);
nand_root.pop_back(); // remove trailing path separator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC it doesn't matter if this path has a trailing separator, the only piece of code that does (or did) care is to make debug logs a little nicer to look at. So I don't think this line is needed but feel free to do it anyways.

PS: Annoyed by my old code in either case, I made a quick refactor that completely removes the weird _length variable (and a few other things) at Starsam80@8911c3b which I might make a PR for if I ever get enough energy.

@leoetlino leoetlino merged commit 9a61514 into dolphin-emu:master Jan 1, 2022
10 checks passed
@AdmiralCurtiss AdmiralCurtiss deleted the user-dir-consistency branch January 1, 2022 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants