3dphotoshoot

diff src/android/assman.c @ 17:aef7f51f6397

resource loading works
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 10 Jun 2015 06:56:27 +0300
parents c6952cc82cca
children 4ca4e3c5a754
line diff
     1.1 --- a/src/android/assman.c	Tue Jun 09 18:38:33 2015 +0300
     1.2 +++ b/src/android/assman.c	Wed Jun 10 06:56:27 2015 +0300
     1.3 @@ -4,11 +4,39 @@
     1.4  #include "native_glue.h"
     1.5  #include "amain.h"
     1.6  
     1.7 -ass_file *ass_fopen(const char *fname)
     1.8 +ass_file *ass_fopen(const char *fname, const char *mode)
     1.9  {
    1.10  	AAsset *ass;
    1.11 +	unsigned int flags = 0;
    1.12 +	char prev = 0;
    1.13  
    1.14 -	if(!(ass = AAssetManager_open(app->activity->assetManager, fname, O_RDONLY))) {
    1.15 +	while(*mode) {
    1.16 +		switch(*mode) {
    1.17 +		case 'r':
    1.18 +			flags |= O_RDONLY;
    1.19 +			break;
    1.20 +
    1.21 +		case 'w':
    1.22 +			flags |= O_WRONLY;
    1.23 +			break;
    1.24 +
    1.25 +		case 'a':
    1.26 +			flags |= O_APPEND;
    1.27 +			break;
    1.28 +
    1.29 +		case '+':
    1.30 +			if(prev == 'w' || prev == 'a') {
    1.31 +				flags |= O_CREAT;
    1.32 +			}
    1.33 +			break;
    1.34 +
    1.35 +		default:
    1.36 +			break;
    1.37 +		}
    1.38 +		prev = *mode++;
    1.39 +	}
    1.40 +
    1.41 +	if(!(ass = AAssetManager_open(app->activity->assetManager, fname, flags))) {
    1.42  		return 0;
    1.43  	}
    1.44  	return (ass_file*)ass;