| Summary: | problem to read file | ||
|---|---|---|---|
| Product: | SDL | Reporter: | lctmp2 |
| Component: | file | Assignee: | Sylvain <sylvain.becker> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | gabomdq, philipp.wiesemann |
| Version: | 2.0.3 | ||
| Hardware: | ARM | ||
| OS: | Android (All) | ||
| Attachments: |
resource file
resource file |
||
Created attachment 1653 [details]
resource file
What path are you using? I simply use «res.bin» because my file is in the assets directory. Did you extract the APK and verified the file is in there and it's contents look ok? Which device are you having problems with? Yes, I have opened the .apk to verify the size of the file. I use an Acer liquid e2 v370 with android 4.2.2. SDL_RWseek() returns -1 if it failed. This could also be checked. Or SDL_RWsize() could be used. Sylvain, can you confirm that you can just drop a file in the apk and read it without specifying the path? This is working.
make sure your asset file is in ./assets/
const char *path = "background.jpg";
SDL_RWops* res = SDL_RWFromFile(path, "rb");
int r = SDL_RWseek(res,0,RW_SEEK_END);
int fileSize = SDL_RWtell(res);
some printf("tell %d filesize", fileSize);
I'm closing this for now. Please reopen it if you have a file in the assets directory that you can't open using the SDL API. Thanks! |
Created attachment 1651 [details] resource file Hello, I try to port my game to android. It works fine on linux and Windows but I have problem to open my resource file with the sdl api. The api seems to read only 6 Bytes. Here is the simple test code I use: SDL_RWops* res = SDL_RWFromFile(path, "rb"); SDL_RWseek(res,0,RW_SEEK_END); int fileSize = SDL_RWtell(res); #ifdef ANDRO __android_log_print(ANDROID_LOG_VERBOSE, APPNAME, "fileSize %d \n", (int)fileSize); #endif printf("fileSize %d \n", (int)fileSize); You can try with the file attached. Thanks.