Any chance that SDL_GetError() tells you anything? Have you checked your
read buffer data to see which operation (read or write) is having problems?
If reading is a problem, can you successfully load assets via SDL_image,
SDL_mixer, or something else that uses SDL_RWops?
Jonny DOn Fri, Sep 20, 2013 at 1:35 PM, Michael Brough wrote:
logcat doesn’t say anything relevant.
SDL_RWFromFile returns something non-NULL, but then trying to
SDL_RWread on that gives nothing / 0 bytes.I got it from hg since the 2.0 release, not sure how to tell whether
it’s the stable/dev branch.thanks,
Message: 2
Date: Thu, 19 Sep 2013 23:20:08 -0400
From: Jonathan Dearborn <@Jonathan_Dearborn>
To: SDL Development List
Subject: Re: [SDL] reading files on android
Message-ID:
<CA+DSiHb1DO–AgBzQ1NC1gV27dtKsYy=
1Q13fm-f6Xafyu5sTw at mail.gmail.com>
Content-Type: text/plain; charset=“iso-8859-1”I’m pretty much doing the same thing. I’m copying an asset from the apk
to
internal storage so that it can be modified by the user (custom game
levels).The only difference I can see is that my code uses SDL_RWFromFile() for
file_out instead of going through a FILE pointer. What problems are you
experiencing? Does logcat tell you anything interesting? Did you do a
sanity check over your paths and the function results? Are you using the
official SDL 2.0 build or are you using the latest from hg?Jonny D
On Thu, Sep 19, 2013 at 10:03 PM, Michael Brough wrote:
Hi, I’m struggling to get basic file IO working on android, using
SDL_RWops to decompress files from the .apk. Am I missing something
really obvious?Here’s the code:
SDL_RWops *file_in = SDL_RWFromFile(filename, “rb”);
sprintf(buf, “%s/%s”, SDL_AndroidGetInternalStoragePath(),filename);
FILE *_file_out = fopen(buf, “wb”);
SDL_RWops *file_out = SDL_RWFromFP(_file_out, SDL_TRUE);
char buffer[CPBUFSIZE];
int size = SDL_RWread(file_in, buffer, 1, CPBUFSIZE);
while (size>0)
{
SDL_RWwrite(file_out, buffer, 1, size);
size = SDL_RWread(file_in, buffer, 1, CPBUFSIZE);
}
SDL_RWclose(file_out);
SDL_RWclose(file_in);I figured it’d be easier to extract everything to internal storage so
I could leave the rest of the code the same as on other platforms.
But now I’ve tried also just loading them straight in with RWops and
there’s definitely a problem in that part.Thanks,
M
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org