cppfw/papki

Android

Closed this issue · 2 comments

Hello again, following on from the SVGDOM android issues.

When I give the SVGDOM a Papki file that is made from a "/asset/something" path. It gets a valid object, but the file seems to instantly return EOF.
This seems to be a C++ problem more so than you're code, but is there a flag, extra call, something that needs to be set up before so it works?

Hi! Well, I suppose you are trying to use papki::fs_file, right? The papki::fs_file is an implementation of papki::file interface to work with normal file system of the OS. This will not work with stuff from assets as those are packed to android application's .apk and so, need to be read from there in a special way. Android NDK offers a set of API functions for reading asset files. Those are declared in android/asset_manager.h header from android NDK.

So, one has to re-implement papki::file interface to read the android assets. I have done it in one of my projects and I think you can copy paste it from there without much modifications. You'll need the asset_file class from here:

https://github.com/igagis/mordavokne/blob/master/src/mordavokne/glue/android/glue.cxx#L264

Then in your program, instead of creating an instance of papki::fs_file you will use instance of asset_file and then it should work.

Thank you for your help.