You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
AssetManager: fix up AssetInputStream
This commit is contained in:
@@ -80,7 +80,7 @@ JNIEXPORT jint JNICALL Java_android_content_res_AssetManager_readAssetChar(JNIEn
|
|||||||
|
|
||||||
struct Asset *asset = _PTR(_asset);
|
struct Asset *asset = _PTR(_asset);
|
||||||
ret = Asset_read(asset, &byte, 1);
|
ret = Asset_read(asset, &byte, 1);
|
||||||
return (ret == 1) ? byte : ret;
|
return (ret == 1) ? byte : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL Java_android_content_res_AssetManager_seekAsset(JNIEnv *env, jobject this, jlong _asset, jlong offset, jint whence)
|
JNIEXPORT jlong JNICALL Java_android_content_res_AssetManager_seekAsset(JNIEnv *env, jobject this, jlong _asset, jlong offset, jint whence)
|
||||||
|
|||||||
@@ -556,10 +556,10 @@ public final class AssetManager {
|
|||||||
seekAsset(mAsset, mMarkPos, -1);
|
seekAsset(mAsset, mMarkPos, -1);
|
||||||
}
|
}
|
||||||
public final int read(byte[] b) throws IOException {
|
public final int read(byte[] b) throws IOException {
|
||||||
return readAsset(mAsset, b, 0, b.length);
|
return readAsset_internal(mAsset, b, 0, b.length);
|
||||||
}
|
}
|
||||||
public final int read(byte[] b, int off, int len) throws IOException {
|
public final int read(byte[] b, int off, int len) throws IOException {
|
||||||
return readAsset(mAsset, b, off, len);
|
return readAsset_internal(mAsset, b, off, len);
|
||||||
}
|
}
|
||||||
public final long skip(long n) throws IOException {
|
public final long skip(long n) throws IOException {
|
||||||
long pos = seekAsset(mAsset, 0, 0);
|
long pos = seekAsset(mAsset, 0, 0);
|
||||||
@@ -581,6 +581,15 @@ public final class AssetManager {
|
|||||||
private long mMarkPos;
|
private long mMarkPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int readAsset_internal(long asset, byte[] b, long offset, long length) throws IOException {
|
||||||
|
int ret = readAsset(asset, b, offset, length);
|
||||||
|
if(ret < 0)
|
||||||
|
throw new IOException();
|
||||||
|
if(ret == 0)
|
||||||
|
ret = -1;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an additional set of assets to the asset manager. This can be
|
* Add an additional set of assets to the asset manager. This can be
|
||||||
* either a directory or ZIP file. Not for use by applications. Returns
|
* either a directory or ZIP file. Not for use by applications. Returns
|
||||||
|
|||||||
Reference in New Issue
Block a user