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.
This commit is contained in:
Fredia Huya-Kouadio
2021-07-10 18:39:31 -07:00
committed by Fredia Huya-Kouadio
parent 100d223736
commit f9c19298ce
40 changed files with 2435 additions and 299 deletions

View File

@@ -34,14 +34,20 @@
AAssetManager *FileAccessAndroid::asset_manager = nullptr;
Ref<FileAccess> 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() {