diff --git a/platform/android/dir_access_jandroid.cpp b/platform/android/dir_access_jandroid.cpp index aea3708f7..78ad9c7b4 100644 --- a/platform/android/dir_access_jandroid.cpp +++ b/platform/android/dir_access_jandroid.cpp @@ -148,7 +148,7 @@ String DirAccessJAndroid::_get_root_string() const { String DirAccessJAndroid::get_current_dir() { String base = _get_root_path(); String bd = current_dir; - if (base != "") { + if (!base.empty()) { bd = current_dir.replace_first(base, ""); } diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp index d6128e211..b16353e31 100644 --- a/platform/android/file_access_android.cpp +++ b/platform/android/file_access_android.cpp @@ -43,17 +43,23 @@ String FileAccessAndroid::get_path_absolute() const { Error FileAccessAndroid::_open(const String &p_path, int p_mode_flags) { path_src = p_path; + String path = fix_path(p_path).simplify_path(); absolute_path = path; - if (path.begins_with("/")) + + if (path.begins_with("/")) { path = path.substr(1, path.length()); - else if (path.begins_with("res://")) + } else if (path.begins_with("res://")) { path = path.substr(6, path.length()); + } ERR_FAIL_COND_V(p_mode_flags & FileAccess::WRITE, ERR_UNAVAILABLE); //can't write on android.. a = AAssetManager_open(asset_manager, path.utf8().get_data(), AASSET_MODE_STREAMING); - if (!a) + + if (!a) { return ERR_CANT_OPEN; + } + //ERR_FAIL_COND_V(!a,ERR_FILE_NOT_FOUND); len = AAsset_getLength(a); pos = 0; @@ -63,8 +69,10 @@ Error FileAccessAndroid::_open(const String &p_path, int p_mode_flags) { } void FileAccessAndroid::close() { - if (!a) + if (!a) { return; + } + AAsset_close(a); a = NULL; } diff --git a/platform/android/java/lib/src/net/relintai/pandemonium/pandemonium/io/file/FileAccessHandler.kt b/platform/android/java/lib/src/net/relintai/pandemonium/pandemonium/io/file/FileAccessHandler.kt index 5f5ac01d9..79f9f885a 100644 --- a/platform/android/java/lib/src/net/relintai/pandemonium/pandemonium/io/file/FileAccessHandler.kt +++ b/platform/android/java/lib/src/net/relintai/pandemonium/pandemonium/io/file/FileAccessHandler.kt @@ -96,7 +96,8 @@ class FileAccessHandler(val context: Context) { private fun hasFileId(fileId: Int) = files.indexOfKey(fileId) >= 0 fun fileOpen(path: String?, modeFlags: Int): Int { - val storageScope = storageScopeIdentifier.identifyStorageScope(path) + val storageScope = storageScopeIdentifier.identifyStorageScope(path) + if (storageScope == StorageScope.UNKNOWN) { return INVALID_FILE_ID }