|
@@ -53,6 +53,7 @@ jmethodID FileAccessFilesystemJAndroid::_file_write = nullptr;
|
|
jmethodID FileAccessFilesystemJAndroid::_file_flush = nullptr;
|
|
jmethodID FileAccessFilesystemJAndroid::_file_flush = nullptr;
|
|
jmethodID FileAccessFilesystemJAndroid::_file_exists = nullptr;
|
|
jmethodID FileAccessFilesystemJAndroid::_file_exists = nullptr;
|
|
jmethodID FileAccessFilesystemJAndroid::_file_last_modified = nullptr;
|
|
jmethodID FileAccessFilesystemJAndroid::_file_last_modified = nullptr;
|
|
|
|
+jmethodID FileAccessFilesystemJAndroid::_file_resize = nullptr;
|
|
|
|
|
|
String FileAccessFilesystemJAndroid::get_path() const {
|
|
String FileAccessFilesystemJAndroid::get_path() const {
|
|
return path_src;
|
|
return path_src;
|
|
@@ -324,6 +325,27 @@ Error FileAccessFilesystemJAndroid::get_error() const {
|
|
return OK;
|
|
return OK;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+Error FileAccessFilesystemJAndroid::resize(int64_t p_length) {
|
|
|
|
+ if (_file_resize) {
|
|
|
|
+ JNIEnv *env = get_jni_env();
|
|
|
|
+ ERR_FAIL_NULL_V(env, FAILED);
|
|
|
|
+ ERR_FAIL_COND_V_MSG(!is_open(), FAILED, "File must be opened before use.");
|
|
|
|
+ int res = env->CallIntMethod(file_access_handler, _file_resize, id, p_length);
|
|
|
|
+ switch (res) {
|
|
|
|
+ case 0:
|
|
|
|
+ return OK;
|
|
|
|
+ case -3:
|
|
|
|
+ return ERR_INVALID_PARAMETER;
|
|
|
|
+ case -2:
|
|
|
|
+ return ERR_FILE_CANT_OPEN;
|
|
|
|
+ default:
|
|
|
|
+ return FAILED;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return ERR_UNAVAILABLE;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
void FileAccessFilesystemJAndroid::flush() {
|
|
void FileAccessFilesystemJAndroid::flush() {
|
|
if (_file_flush) {
|
|
if (_file_flush) {
|
|
JNIEnv *env = get_jni_env();
|
|
JNIEnv *env = get_jni_env();
|
|
@@ -383,6 +405,7 @@ void FileAccessFilesystemJAndroid::setup(jobject p_file_access_handler) {
|
|
_file_flush = env->GetMethodID(cls, "fileFlush", "(I)V");
|
|
_file_flush = env->GetMethodID(cls, "fileFlush", "(I)V");
|
|
_file_exists = env->GetMethodID(cls, "fileExists", "(Ljava/lang/String;)Z");
|
|
_file_exists = env->GetMethodID(cls, "fileExists", "(Ljava/lang/String;)Z");
|
|
_file_last_modified = env->GetMethodID(cls, "fileLastModified", "(Ljava/lang/String;)J");
|
|
_file_last_modified = env->GetMethodID(cls, "fileLastModified", "(Ljava/lang/String;)J");
|
|
|
|
+ _file_resize = env->GetMethodID(cls, "fileResize", "(IJ)I");
|
|
}
|
|
}
|
|
|
|
|
|
void FileAccessFilesystemJAndroid::close() {
|
|
void FileAccessFilesystemJAndroid::close() {
|