summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/core_bind.cpp18
-rw-r--r--core/core_bind.h3
-rw-r--r--doc/classes/OS.xml25
3 files changed, 46 insertions, 0 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index 60759cd71c..912512d993 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -426,6 +426,21 @@ String _OS::get_external_data_dir() const {
return OS::get_singleton()->get_external_data_dir();
}
+String _OS::get_config_dir() const {
+ // Exposed as `get_config_dir()` instead of `get_config_path()` for consistency with other exposed OS methods.
+ return OS::get_singleton()->get_config_path();
+}
+
+String _OS::get_data_dir() const {
+ // Exposed as `get_data_dir()` instead of `get_data_path()` for consistency with other exposed OS methods.
+ return OS::get_singleton()->get_data_path();
+}
+
+String _OS::get_cache_dir() const {
+ // Exposed as `get_cache_dir()` instead of `get_cache_path()` for consistency with other exposed OS methods.
+ return OS::get_singleton()->get_cache_path();
+}
+
bool _OS::is_debug_build() const {
#ifdef DEBUG_ENABLED
return true;
@@ -518,6 +533,9 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_user_data_dir"), &_OS::get_user_data_dir);
ClassDB::bind_method(D_METHOD("get_external_data_dir"), &_OS::get_external_data_dir);
ClassDB::bind_method(D_METHOD("get_system_dir", "dir"), &_OS::get_system_dir);
+ ClassDB::bind_method(D_METHOD("get_config_dir"), &_OS::get_config_dir);
+ ClassDB::bind_method(D_METHOD("get_data_dir"), &_OS::get_data_dir);
+ ClassDB::bind_method(D_METHOD("get_cache_dir"), &_OS::get_cache_dir);
ClassDB::bind_method(D_METHOD("get_unique_id"), &_OS::get_unique_id);
ClassDB::bind_method(D_METHOD("print_all_textures_by_size"), &_OS::print_all_textures_by_size);
diff --git a/core/core_bind.h b/core/core_bind.h
index b161effe95..5ab81547d7 100644
--- a/core/core_bind.h
+++ b/core/core_bind.h
@@ -230,6 +230,9 @@ public:
String get_user_data_dir() const;
String get_external_data_dir() const;
+ String get_config_dir() const;
+ String get_data_dir() const;
+ String get_cache_dir() const;
Error set_thread_name(const String &p_name);
Thread::ID get_thread_caller_id() const;
diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml
index 0789a7d231..a9396306f4 100644
--- a/doc/classes/OS.xml
+++ b/doc/classes/OS.xml
@@ -136,6 +136,14 @@
Returns the keycode of the given string (e.g. "Escape").
</description>
</method>
+ <method name="get_cache_dir" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ Returns the [i]global[/i] cache data directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the [code]XDG_CACHE_HOME[/code] environment variable before starting the project. See [url=https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html]File paths in Godot projects[/url] in the documentation for more information. See also [method get_config_dir] and [method get_data_dir].
+ Not to be confused with [method get_user_data_dir], which returns the [i]project-specific[/i] user data path.
+ </description>
+ </method>
<method name="get_cmdline_args">
<return type="PackedStringArray">
</return>
@@ -167,6 +175,14 @@
[/codeblocks]
</description>
</method>
+ <method name="get_config_dir" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ Returns the [i]global[/i] user configuration directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the [code]XDG_CONFIG_HOME[/code] environment variable before starting the project. See [url=https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html]File paths in Godot projects[/url] in the documentation for more information. See also [method get_cache_dir] and [method get_data_dir].
+ Not to be confused with [method get_user_data_dir], which returns the [i]project-specific[/i] user data path.
+ </description>
+ </method>
<method name="get_connected_midi_inputs">
<return type="PackedStringArray">
</return>
@@ -176,6 +192,14 @@
[b]Note:[/b] This method is implemented on Linux, macOS and Windows.
</description>
</method>
+ <method name="get_data_dir" qualifiers="const">
+ <return type="String">
+ </return>
+ <description>
+ Returns the [i]global[/i] user data directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the [code]XDG_DATA_HOME[/code] environment variable before starting the project. See [url=https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html]File paths in Godot projects[/url] in the documentation for more information. See also [method get_cache_dir] and [method get_config_dir].
+ Not to be confused with [method get_user_data_dir], which returns the [i]project-specific[/i] user data path.
+ </description>
+ </method>
<method name="get_environment" qualifiers="const">
<return type="String">
</return>
@@ -310,6 +334,7 @@
On macOS, this is [code]~/Library/Application Support/Godot/app_userdata/[project_name][/code], or [code]~/Library/Application Support/[custom_name][/code] if [code]use_custom_user_dir[/code] is set.
On Windows, this is [code]%APPDATA%\Godot\app_userdata\[project_name][/code], or [code]%APPDATA%\[custom_name][/code] if [code]use_custom_user_dir[/code] is set. [code]%APPDATA%[/code] expands to [code]%USERPROFILE%\AppData\Roaming[/code].
If the project name is empty, [code]user://[/code] falls back to [code]res://[/code].
+ Not to be confused with [method get_data_dir], which returns the [i]global[/i] (non-project-specific) user data directory.
</description>
</method>
<method name="has_environment" qualifiers="const">