api-impl/android/content/res/AssetManager.java: fix lack of throwing exception on failure

ClassLoader.getResourceAsStream() eats the IOException, so we need
to throw a new one when it returns null. We also report the errno
we got from openAsset.
This commit is contained in:
Mis012
2023-06-22 14:35:55 +02:00
parent 0a9591c474
commit 9f87192a78

View File

@@ -343,7 +343,11 @@ public final class AssetManager {
}
}
// alternatively load directly from APK
return ClassLoader.getSystemClassLoader().getResourceAsStream("assets/" + fileName);
InputStream ret = ClassLoader.getSystemClassLoader().getResourceAsStream("assets/" + fileName);
if(ret == null)
throw new FileNotFoundException("Asset file: " + fileName + ", errno: " + asset);
return ret;
}
public final AssetFileDescriptor openFd(String fileName)