summaryrefslogtreecommitdiffstats
path: root/core/core_bind.cpp
diff options
context:
space:
mode:
authorDaylily-Zeleen <daylily-zeleen@foxmail.com>2022-12-07 11:33:35 +0800
committerDaylily-Zeleen <daylily-zeleen@foxmail.com>2023-04-25 11:29:32 +0800
commitb12ced0a2693d4983e08716005d4a854fce116f1 (patch)
tree67b799386354d016777ecb2a43e9e43372405632 /core/core_bind.cpp
parent6f1a52b017930afb851691e6852ce40eb93c30a9 (diff)
downloadredot-engine-b12ced0a2693d4983e08716005d4a854fce116f1.tar.gz
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 f2eb7823e2..3fce665763 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();
}
@@ -549,6 +558,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);