Skip to content

Conversation

@neebyA
Copy link
Contributor

@neebyA neebyA commented Apr 27, 2025

On macOS, trying to open save directory locations through the context menu usually results in errors like:

Failed to open URL "file:/Users/xxxxx/Library/Application Support/Cemu/mlc01/usr/save/00050000/xxxxxxxx" in default browser. (error 0: Undefined error: 0)

This is due to the default MLC path on macOS being located at ~/Library/Application\ Support/Cemu/mlc01, which contains a space. I tried escaping with a \ or surrounding the path with "", but it appears that since wxLaunchDefaultBrowser is being used then URI encoding is required. I couldn't find a URI encoding function in either <wx/uri.h> or <wx/url.h>, so I just did a manual string replacement of all spaces.

Alternatively, it's possible to just use wxLaunchDefaultApplication instead like this:

Cemu/src/gui/MainWindow.cpp

Lines 683 to 684 in b089ae5

else if(id == MAINFRAME_MENU_ID_FILE_OPEN_MLC_FOLDER)
wxLaunchDefaultApplication(wxHelper::FromPath(ActiveSettings::GetMlcPath()));

I have not tested this on Linux or Windows, though this change doesn't seem like it would break anything in either

Comment on lines 692 to 694
// escape any spaces in file path
std::string saveFolder = boost::replace_all_copy(_pathToUtf8(gameInfo.GetSaveFolder()), " ", "%20");
wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("file:{}", saveFolder)));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
// escape any spaces in file path
std::string saveFolder = boost::replace_all_copy(_pathToUtf8(gameInfo.GetSaveFolder()), " ", "%20");
wxLaunchDefaultBrowser(wxHelper::FromUtf8(fmt::format("file:{}", saveFolder)));
// handles any spaces in file path
wxLaunchDefaultApplication(wxHelper::FromPath(gameInfo.GetSaveFolder()));

Confirmed that this also works. Perhaps it should be preferred as it does not require any additional string editing?

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably best to use wxHelper::FromPath, as it can then handle any special characters in the string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@JaimieVandenbergh
Copy link

Thanks for this - it's been a longstanding minor annoyance :)
Note that when you right-click a game and choose "Game directory" "Update directory" "DLC directory" these all suffer the same issue as "Save directory" and would probably be fixable the same way.

Open directories through default file handler rather than file URI scheme
@neebyA
Copy link
Contributor Author

neebyA commented Apr 27, 2025

Opening directories from the title manager also saw this issue so I updated that in the latest commit, as well as the for the game, update, and DLC directories, as trying to open them would also lead to errors if the directory paths included any spaces.

@neebyA neebyA requested a review from emiyl April 30, 2025 00:47
@Exzap Exzap merged commit fa7ae84 into cemu-project:main May 4, 2025
5 checks passed
@Exzap
Copy link
Member

Exzap commented May 4, 2025

Thanks!

@neebyA neebyA deleted the save-path branch May 4, 2025 21:30
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.

4 participants