From b3a962945e82097fd472c6e1724785b11eaaa32f Mon Sep 17 00:00:00 2001 From: Marcel Admiraal Date: Tue, 8 Jun 2021 17:43:10 +0100 Subject: Add OS.get_external_data_dir() to get Android external directory --- core/core_bind.cpp | 5 +++++ core/core_bind.h | 1 + core/os/os.cpp | 5 +++++ core/os/os.h | 1 + 4 files changed, 12 insertions(+) (limited to 'core') diff --git a/core/core_bind.cpp b/core/core_bind.cpp index ed4387a1b9..fe0166d0e6 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -643,6 +643,10 @@ String _OS::get_user_data_dir() const { return OS::get_singleton()->get_user_data_dir(); } +String _OS::get_external_data_dir() const { + return OS::get_singleton()->get_external_data_dir(); +} + bool _OS::is_debug_build() const { #ifdef DEBUG_ENABLED return true; @@ -743,6 +747,7 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_static_memory_peak_usage"), &_OS::get_static_memory_peak_usage); 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_unique_id"), &_OS::get_unique_id); diff --git a/core/core_bind.h b/core/core_bind.h index d05353bf0f..c8b0a4d7da 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -237,6 +237,7 @@ public: String get_system_dir(SystemDir p_dir) const; String get_user_data_dir() const; + String get_external_data_dir() const; Error set_thread_name(const String &p_name); Thread::ID get_thread_caller_id() const; diff --git a/core/os/os.cpp b/core/os/os.cpp index ca1b798e11..c5463cf216 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -310,6 +310,11 @@ String OS::get_user_data_dir() const { return "."; } +// Android OS path to app's external data storage +String OS::get_external_data_dir() const { + return get_user_data_dir(); +}; + // Absolute path to res:// String OS::get_resource_dir() const { return ProjectSettings::get_singleton()->get_resource_path(); diff --git a/core/os/os.h b/core/os/os.h index 7198607237..5bf9dc9288 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -252,6 +252,7 @@ public: virtual String get_bundle_resource_dir() const; virtual String get_user_data_dir() const; + virtual String get_external_data_dir() const; virtual String get_resource_dir() const; enum SystemDir { -- cgit v1.2.3