Skip to content

Commit

Permalink
Fix issue with get_current_dir() returning the wrong path on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
m4gr3d committed Aug 20, 2022
1 parent 502a6a7 commit b5e1096
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions platform/android/dir_access_jandroid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,20 @@ String DirAccessJAndroid::get_drive(int p_drive) {
}
}

String DirAccessJAndroid::get_current_dir() {
String base = _get_root_path();
String bd = current_dir;
if (base != "") {
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) {
Expand Down
1 change: 1 addition & 0 deletions platform/android/dir_access_jandroid.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class DirAccessJAndroid : public DirAccessUnix {
virtual String get_drive(int p_drive) override;

virtual Error change_dir(String p_dir) override; ///< can be relative or absolute, return false on success
virtual String get_current_dir() override; ///< return current dir location

virtual bool file_exists(String p_file) override;
virtual bool dir_exists(String p_dir) override;
Expand Down

0 comments on commit b5e1096

Please sign in to comment.