From f9c19298ce9ba7a9a9943949b40c757979706a5a Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Sat, 10 Jul 2021 18:39:31 -0700 Subject: Add full support for Android scoped storage. This was done by refactoring directory and file access handling for the Android platform so that any general filesystem access type go through the Android layer. This allows us to validate whether the access is unrestricted, or whether it falls under scoped storage and thus act appropriately. --- platform/android/file_access_android.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'platform/android/file_access_android.cpp') diff --git a/platform/android/file_access_android.cpp b/platform/android/file_access_android.cpp index 4bb8a13bb6..ace7636e6c 100644 --- a/platform/android/file_access_android.cpp +++ b/platform/android/file_access_android.cpp @@ -34,14 +34,20 @@ AAssetManager *FileAccessAndroid::asset_manager = nullptr; -Ref FileAccessAndroid::create_android() { - return memnew(FileAccessAndroid); +String FileAccessAndroid::get_path() const { + return path_src; +} + +String FileAccessAndroid::get_path_absolute() const { + return absolute_path; } Error FileAccessAndroid::_open(const String &p_path, int p_mode_flags) { _close(); + path_src = p_path; String path = fix_path(p_path).simplify_path(); + absolute_path = path; if (path.begins_with("/")) { path = path.substr(1, path.length()); } else if (path.begins_with("res://")) { @@ -134,7 +140,7 @@ uint64_t FileAccessAndroid::get_buffer(uint8_t *p_dst, uint64_t p_length) const } Error FileAccessAndroid::get_error() const { - return eof ? ERR_FILE_EOF : OK; //not sure what else it may happen + return eof ? ERR_FILE_EOF : OK; // not sure what else it may happen } void FileAccessAndroid::flush() { -- cgit v1.2.3