The resource management of NDK is ****** unfriendly. The files in the asset fold will be zipped, can not be accessed by NDK directly. Fortunately, SDL2 has file io wrapper. Here is a sample to read a file. Note that, the root path is asset.
SDL_RWops *file = SDL_RWFromFile("yourfile.txt", "r");
size_t len;
len = SDL_RWseek(file, 0, SEEK_END);
SDL_RWseek(file, 0, SEEK_SET);
char * fileChar = new char[len + 1];
SDL_RWread(file, fileChar, sizeof(char), len);
fileChar[len] = '\0';
SDL_RWclose(file);
No comments:
Post a Comment