nuclear@16: #include nuclear@15: #include nuclear@16: #include "assman.h" nuclear@16: #include "native_glue.h" nuclear@16: #include "amain.h" nuclear@15: nuclear@17: ass_file *ass_fopen(const char *fname, const char *mode) nuclear@15: { nuclear@16: AAsset *ass; nuclear@17: unsigned int flags = 0; nuclear@17: char prev = 0; nuclear@16: nuclear@17: while(*mode) { nuclear@17: switch(*mode) { nuclear@17: case 'r': nuclear@17: flags |= O_RDONLY; nuclear@17: break; nuclear@17: nuclear@17: case 'w': nuclear@17: flags |= O_WRONLY; nuclear@17: break; nuclear@17: nuclear@17: case 'a': nuclear@17: flags |= O_APPEND; nuclear@17: break; nuclear@17: nuclear@17: case '+': nuclear@17: if(prev == 'w' || prev == 'a') { nuclear@17: flags |= O_CREAT; nuclear@17: } nuclear@17: break; nuclear@17: nuclear@17: default: nuclear@17: break; nuclear@17: } nuclear@17: prev = *mode++; nuclear@17: } nuclear@17: nuclear@17: if(!(ass = AAssetManager_open(app->activity->assetManager, fname, flags))) { nuclear@16: return 0; nuclear@16: } nuclear@16: return (ass_file*)ass; nuclear@15: } nuclear@16: nuclear@16: void ass_fclose(ass_file *fp) nuclear@16: { nuclear@16: AAsset_close((AAsset*)fp); nuclear@16: } nuclear@16: nuclear@16: long ass_fseek(ass_file *fp, long offs, int whence) nuclear@16: { nuclear@16: return AAsset_seek((AAsset*)fp, offs, whence); nuclear@16: } nuclear@16: nuclear@21: long ass_ftell(ass_file *fp) nuclear@21: { nuclear@21: return AAsset_seek((AAsset*)fp, 0, SEEK_SET); nuclear@21: } nuclear@21: nuclear@16: size_t ass_fread(void *buf, size_t size, size_t count, ass_file *fp) nuclear@16: { nuclear@16: return AAsset_read((AAsset*)fp, buf, size * count) / size; nuclear@16: }