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

Expose OS data directory getter methods (3.x) #49732

Merged
merged 1 commit into from
Jun 19, 2021
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
18 changes: 18 additions & 0 deletions core/bind/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,21 @@ int64_t _OS::get_native_handle(HandleType p_handle_type) {
return (int64_t)OS::get_singleton()->get_native_handle(p_handle_type);
}

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;
Expand Down Expand Up @@ -1321,6 +1336,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("is_ok_left_and_cancel_right"), &_OS::is_ok_left_and_cancel_right);
Expand Down
3 changes: 3 additions & 0 deletions core/bind/core_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ class _OS : public Object {

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;

void alert(const String &p_alert, const String &p_title = "ALERT!");

Expand Down
25 changes: 25 additions & 0 deletions doc/classes/OS.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@
Returns the audio driver name for the given index.
</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="PoolStringArray">
</return>
Expand All @@ -168,6 +176,14 @@
[/codeblock]
</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="PoolStringArray">
</return>
Expand All @@ -184,6 +200,14 @@
Returns the currently used video driver, using one of the values from [enum VideoDriver].
</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_date" qualifiers="const">
<return type="Dictionary">
</return>
Expand Down Expand Up @@ -570,6 +594,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="get_video_driver_count" qualifiers="const">
Expand Down