|
@@ -376,8 +376,14 @@ String DirAccessPack::get_drive(int p_drive) {
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
-Error DirAccessPack::change_dir(String p_dir) {
|
|
|
+PackedData::PackedDir *DirAccessPack::_find_dir(String p_dir) {
|
|
|
String nd = p_dir.replace("\\", "/");
|
|
|
+
|
|
|
+ // Special handling since simplify_path() will forbid it
|
|
|
+ if (p_dir == "..") {
|
|
|
+ return current->parent;
|
|
|
+ }
|
|
|
+
|
|
|
bool absolute = false;
|
|
|
if (nd.begins_with("res://")) {
|
|
|
nd = nd.replace_first("res://", "");
|
|
@@ -417,13 +423,21 @@ Error DirAccessPack::change_dir(String p_dir) {
|
|
|
pd = pd->subdirs[p];
|
|
|
|
|
|
} else {
|
|
|
- return ERR_INVALID_PARAMETER;
|
|
|
+ return nullptr;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- current = pd;
|
|
|
+ return pd;
|
|
|
+}
|
|
|
|
|
|
- return OK;
|
|
|
+Error DirAccessPack::change_dir(String p_dir) {
|
|
|
+ PackedData::PackedDir *pd = _find_dir(p_dir);
|
|
|
+ if (pd) {
|
|
|
+ current = pd;
|
|
|
+ return OK;
|
|
|
+ } else {
|
|
|
+ return ERR_INVALID_PARAMETER;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
String DirAccessPack::get_current_dir(bool p_include_drive) {
|
|
@@ -441,13 +455,17 @@ String DirAccessPack::get_current_dir(bool p_include_drive) {
|
|
|
bool DirAccessPack::file_exists(String p_file) {
|
|
|
p_file = fix_path(p_file);
|
|
|
|
|
|
- return current->files.has(p_file);
|
|
|
+ PackedData::PackedDir *pd = _find_dir(p_file.get_base_dir());
|
|
|
+ if (!pd) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return pd->files.has(p_file.get_file());
|
|
|
}
|
|
|
|
|
|
bool DirAccessPack::dir_exists(String p_dir) {
|
|
|
p_dir = fix_path(p_dir);
|
|
|
|
|
|
- return current->subdirs.has(p_dir);
|
|
|
+ return _find_dir(p_dir) != nullptr;
|
|
|
}
|
|
|
|
|
|
Error DirAccessPack::make_dir(String p_dir) {
|