# HG changeset patch # User John Tsiombikas # Date 1433864313 -10800 # Node ID c6952cc82ccaeb072ac7c8305b7cbd2f4d958778 # Parent 2d48f65da3576cd232c690f65840be4e957d17ef asset manager, android version diff -r 2d48f65da357 -r c6952cc82cca src/android/amain.c --- a/src/android/amain.c Sun Jun 07 20:40:37 2015 +0300 +++ b/src/android/amain.c Tue Jun 09 18:38:33 2015 +0300 @@ -3,6 +3,7 @@ #include #include #include +#include "amain.h" #include "native_glue.h" #include "logger.h" #include "game.h" @@ -20,7 +21,6 @@ static EGLSurface surf; static EGLContext ctx; -static struct android_app *app; static int win_width, win_height; static int init_done; diff -r 2d48f65da357 -r c6952cc82cca src/android/amain.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/android/amain.h Tue Jun 09 18:38:33 2015 +0300 @@ -0,0 +1,6 @@ +#ifndef AMAIN_H_ +#define AMAIN_H_ + +struct android_app *app; + +#endif /* AMAIN_H_ */ diff -r 2d48f65da357 -r c6952cc82cca src/android/assman.c --- a/src/android/assman.c Sun Jun 07 20:40:37 2015 +0300 +++ b/src/android/assman.c Tue Jun 09 18:38:33 2015 +0300 @@ -1,5 +1,30 @@ +#include #include +#include "assman.h" +#include "native_glue.h" +#include "amain.h" -void *ass_open(const char *fname) +ass_file *ass_fopen(const char *fname) { + AAsset *ass; + + if(!(ass = AAssetManager_open(app->activity->assetManager, fname, O_RDONLY))) { + return 0; + } + return (ass_file*)ass; } + +void ass_fclose(ass_file *fp) +{ + AAsset_close((AAsset*)fp); +} + +long ass_fseek(ass_file *fp, long offs, int whence) +{ + return AAsset_seek((AAsset*)fp, offs, whence); +} + +size_t ass_fread(void *buf, size_t size, size_t count, ass_file *fp) +{ + return AAsset_read((AAsset*)fp, buf, size * count) / size; +} diff -r 2d48f65da357 -r c6952cc82cca src/assman.h --- a/src/assman.h Sun Jun 07 20:40:37 2015 +0300 +++ b/src/assman.h Tue Jun 09 18:38:33 2015 +0300 @@ -1,11 +1,15 @@ #ifndef ASSMAN_H_ #define ASSMAN_H_ -void *ass_open(const char *fname); -void ass_close(void *fp); -void ass_rewind(void *fp); -long ass_seek(void *fp, long offs, int whence); -long ass_read(void *fp, void *buf, long bytes); +#include + +typedef void ass_file; + +ass_file *ass_fopen(const char *fname); +void ass_fclose(ass_file *fp); +long ass_fseek(ass_file *fp, long offs, int whence); + +size_t ass_fread(void *buf, size_t size, size_t count, ass_file *fp); #endif /* ASSMAN_H_ */