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

Fix the fallback logic of OS::shell_show_in_file_manager. #79087

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions core/os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,14 @@ Error OS::shell_open(String p_uri) {
}

Error OS::shell_show_in_file_manager(String p_path, bool p_open_folder) {
if (!p_path.begins_with("file://")) {
p_path = String("file://") + p_path;
}
if (!p_path.ends_with("/")) {
p_path = p_path.trim_prefix("file://");

if (!DirAccess::dir_exists_absolute(p_path)) {
p_path = p_path.get_base_dir();
}

p_path = String("file://") + p_path;

return shell_open(p_path);
}
// implement these with the canvas?
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/OS.xml
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@
Requests the OS to open the file manager, then navigate to the given [param file_or_dir_path] and select the target file or folder.
If [param file_or_dir_path] is a valid directory path, and [param open_folder] is [code]true[/code], the method will open the file manager and enter the target folder without selecting anything.
Use [method ProjectSettings.globalize_path] to convert a [code]res://[/code] or [code]user://[/code] path into a system path for use with this method.
[b]Note:[/b] Currently this method is only implemented on Windows. On other platforms, it will fallback to [method shell_open] with a directory path for [param file_or_dir_path].
[b]Note:[/b] Currently this method is only implemented on Windows and macOS. On other platforms, it will fallback to [method shell_open] with a directory path of [param file_or_dir_path] with prefix [code]file://[/code].
</description>
</method>
<method name="unset_environment" qualifiers="const">
Expand Down
Loading