summaryrefslogtreecommitdiffstats
path: root/core/core_bind.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-04-25 09:57:27 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-04-25 09:57:27 +0200
commit76d33d187f65dfea52d0f7219b30c73dc468abbb (patch)
treea0046aaaec0a36d0fb979ae958c4b50f7d2c65f4 /core/core_bind.cpp
parentd5b8a0fc373aa99c0618db3472947db4d6d7c933 (diff)
parentb12ced0a2693d4983e08716005d4a854fce116f1 (diff)
downloadredot-engine-76d33d187f65dfea52d0f7219b30c73dc468abbb.tar.gz
Merge pull request #69698 from Daylily-Zeleen/daylily-zeleen/show_in_explorer
Implement and expose OS::shell_show_in_file_manager()
Diffstat (limited to 'core/core_bind.cpp')
-rw-r--r--core/core_bind.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index c7cd797f4d..50587bb402 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -257,6 +257,15 @@ Error OS::shell_open(String p_uri) {
return ::OS::get_singleton()->shell_open(p_uri);
}
+Error OS::shell_show_in_file_manager(String p_path, bool p_open_folder) {
+ if (p_path.begins_with("res://")) {
+ WARN_PRINT("Attempting to explore file path with the \"res://\" protocol. Use `ProjectSettings.globalize_path()` to convert a Godot-specific path to a system path before opening it with `OS.shell_show_in_file_manager()`.");
+ } else if (p_path.begins_with("user://")) {
+ WARN_PRINT("Attempting to explore file path with the \"user://\" protocol. Use `ProjectSettings.globalize_path()` to convert a Godot-specific path to a system path before opening it with `OS.shell_show_in_file_manager()`.");
+ }
+ return ::OS::get_singleton()->shell_show_in_file_manager(p_path, p_open_folder);
+}
+
String OS::read_string_from_stdin() {
return ::OS::get_singleton()->get_stdin_string();
}
@@ -553,6 +562,7 @@ void OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("create_instance", "arguments"), &OS::create_instance);
ClassDB::bind_method(D_METHOD("kill", "pid"), &OS::kill);
ClassDB::bind_method(D_METHOD("shell_open", "uri"), &OS::shell_open);
+ ClassDB::bind_method(D_METHOD("shell_show_in_file_manager", "file_or_dir_path", "open_folder"), &OS::shell_show_in_file_manager, DEFVAL(true));
ClassDB::bind_method(D_METHOD("is_process_running", "pid"), &OS::is_process_running);
ClassDB::bind_method(D_METHOD("get_process_id"), &OS::get_process_id);