1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Follow-Up Fix Directory Open

(cherry picked from commit 6952458538)
This commit is contained in:
Nathan Franke
2020-07-09 14:23:59 -05:00
committed by Rémi Verschelde
parent 4a0fe1adb3
commit ec787f0134
2 changed files with 16 additions and 9 deletions

View File

@@ -2421,8 +2421,15 @@ int _Directory::get_current_drive() {
}
Error _Directory::change_dir(String p_dir) {
ERR_FAIL_COND_V_MSG(!is_open(), ERR_UNCONFIGURED, "Directory must be opened before use.");
return d->change_dir(p_dir);
ERR_FAIL_COND_V_MSG(!d, ERR_UNCONFIGURED, "Directory is not configured properly.");
Error err = d->change_dir(p_dir);
if (err != OK) {
return err;
}
dir_open = true;
return OK;
}
String _Directory::get_current_dir() {
ERR_FAIL_COND_V_MSG(!is_open(), "", "Directory must be opened before use.");
@@ -2450,8 +2457,7 @@ Error _Directory::make_dir_recursive(String p_dir) {
}
bool _Directory::file_exists(String p_file) {
ERR_FAIL_COND_V_MSG(!is_open(), false, "Directory must be opened before use.");
ERR_FAIL_COND_V_MSG(!d, false, "Directory is not configured properly.");
if (!p_file.is_rel_path()) {
return FileAccess::exists(p_file);
}
@@ -2460,17 +2466,16 @@ bool _Directory::file_exists(String p_file) {
}
bool _Directory::dir_exists(String p_dir) {
ERR_FAIL_COND_V_MSG(!is_open(), false, "Directory must be opened before use.");
ERR_FAIL_COND_V_MSG(!d, false, "Directory is not configured properly.");
if (!p_dir.is_rel_path()) {
DirAccess *d = DirAccess::create_for_path(p_dir);
bool exists = d->dir_exists(p_dir);
memdelete(d);
return exists;
} else {
return d->dir_exists(p_dir);
}
return d->dir_exists(p_dir);
}
int _Directory::get_space_left() {