I know that is possible to read a file from AssetFileDescriptor content like offset and length. I'm passing to JNI data in the following way:
val resources = context.get()!!.resources
val file = resources.openRawResourceFd(rawFileId) // example: R.raw.you_file
val fileOffset = file.startOffset.toInt()
val fileLength = file.length.toInt()
try {
file.parcelFileDescriptor.close()
} catch (e: IOException) {
Log.e("error", "Couldn't close")
}
try {
this.id = ndkJNIBind(
context.get()!!.packageResourcePath, fileLength, fileOffset)
} catch (e: UnsatisfiedLinkError) {
Log.e("error", "Couldn't do ndkJNIBind")
}
Now, in NDK side how can I read the file?
extern "C" JNICALL JNIEXPORT
void Java_package_TheClass_ndkJNIBind(
JNIEnv* env,
jobject __unused,
jstring path,
jint fileLength,
jint fileOffset
) {
// TODO: ??????
}