diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-08-23 16:15:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-23 16:15:02 +0200 |
commit | 90854094929c0b8569bf07a6cdb5d299bd8ea5e6 (patch) | |
tree | 46e58d5ae55b318f0130c530f50225d6fa8a1163 /platform/android | |
parent | c7a7aad30d2b5a7a3ca6ddc3b8f556b797480d39 (diff) | |
parent | a356e498030be5f497e35f0dd2d0228c7a8c678f (diff) |
Merge pull request #64414 from m4gr3d/fix_get_current_dir_main
Diffstat (limited to 'platform/android')
-rw-r--r-- | platform/android/dir_access_jandroid.cpp | 14 | ||||
-rw-r--r-- | platform/android/dir_access_jandroid.h | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index eb344d3b43..428135de56 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -135,6 +135,20 @@ String DirAccessJAndroid::get_drive(int p_drive) { } } +String DirAccessJAndroid::get_current_dir(bool p_include_drive) const { + String base = _get_root_path(); + String bd = current_dir; + if (!base.is_empty()) { + bd = current_dir.replace_first(base, ""); + } + + if (bd.begins_with("/")) { + return _get_root_string() + bd.substr(1, bd.length()); + } else { + return _get_root_string() + bd; + } +} + Error DirAccessJAndroid::change_dir(String p_dir) { String new_dir = get_absolute_path(p_dir); if (new_dir == current_dir) { diff --git a/platform/android/dir_access_jandroid.h b/platform/android/dir_access_jandroid.h index d469c9d317..5b7b4a9c4d 100644 --- a/platform/android/dir_access_jandroid.h +++ b/platform/android/dir_access_jandroid.h @@ -67,6 +67,7 @@ public: virtual int get_drive_count() override; virtual String get_drive(int p_drive) override; + virtual String get_current_dir(bool p_include_drive = true) const override; ///< return current dir location virtual Error change_dir(String p_dir) override; ///< can be relative or absolute, return false on success |