I’m using the following code (found on internet) to get the size of a file, because i’m reading a text file with SDL_RWFromFile.
It’s working on Linux and Windows, but I can’t get the file size on Android.
I did some search on internet and get examples but it doesn’t work:
int get_file_size(string filename)
FILE *p_file = NULL;
p_file = fopen(filename.c_str(),“rb”);
int size = ftell(p_file);
SDL_RWops* fileIN = SDL_RWFromFile( NomLecture.c_str(), “r+b” );
if( fileIN == NULL )
SDL_Log( “ERREUR Warning: Unable to open fileIN! SDL Error: %s\n”, SDL_GetError() ); //
unsigned char gDataLu[ InfoFileSize ];
SDL_RWread( fileIN, &gDataLu, ( sizeof ( unsigned char ) ), InfoFileSize );
SDL_RWclose( fileIN ); // Fermeture du fichier
Could you please help me to get the size of file for reading it on Android?
Can we load the file without giving the filesize?
Thanks a lot for your help.