diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-04-29 16:07:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-29 16:07:34 +0200 |
commit | b99b212855ed3d208405bf5f12f43034e5f960cf (patch) | |
tree | 659dc1ca3f08874982aa0c6cd3cb84f095ff5344 | |
parent | f6e29addd433130100061935b9a2b8f6de38254b (diff) | |
parent | d46e411b4475ffd5cc6871b5e5dc70150d930164 (diff) |
Merge pull request #38307 from Calinou/shell-open-res-user-warning
Warn when trying to open `res://` or `user://` with `OS.shell_open()`
-rw-r--r-- | core/bind/core_bind.cpp | 5 | ||||
-rw-r--r-- | doc/classes/OS.xml | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index e8955c05df..e2774deb3c 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -237,6 +237,11 @@ String _OS::get_executable_path() const { Error _OS::shell_open(String p_uri) { + if (p_uri.begins_with("res://")) { + WARN_PRINT("Attempting to open an URL with the \"res://\" protocol. Use `ProjectSettings.globalize_path()` to convert a Godot-specific path to a system path before opening it with `OS.shell_open()`."); + } else if (p_uri.begins_with("user://")) { + WARN_PRINT("Attempting to open an URL with the \"user://\" protocol. Use `ProjectSettings.globalize_path()` to convert a Godot-specific path to a system path before opening it with `OS.shell_open()`."); + } return OS::get_singleton()->shell_open(p_uri); }; diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index db79ee7765..6a70297f40 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -484,6 +484,7 @@ - [code]OS.shell_open("C:\\Users\name\Downloads")[/code] on Windows opens the file explorer at the user's Downloads folder. - [code]OS.shell_open("https://godotengine.org")[/code] opens the default web browser on the official Godot website. - [code]OS.shell_open("mailto:example@example.com")[/code] opens the default email client with the "To" field set to [code]example@example.com[/code]. See [url=https://blog.escapecreative.com/customizing-mailto-links/]Customizing [code]mailto:[/code] Links[/url] for a list of fields that can be added. + 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] This method is implemented on Android, iOS, HTML5, Linux, macOS and Windows. </description> </method> |