Merge pull request #64414 from m4gr3d/fix_get_current_dir_main

This commit is contained in:
Rémi Verschelde 2022-08-23 16:15:02 +02:00 committed by GitHub
commit 9085409492
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -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) {

View File

@ -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