Platform: Android
I am trying to read a simple text file with SDL_RWops::read() file that is 1.7 megs in size. I have successfully read loads of text files already smaller than 500 kb, but my program crashes at that function call with larger files. Is there a file size limit to the function? Is there a work around?
I am on my phone, so can’t properly format the code here, but here is roughly the essential parts:
SDL_RWops *io = NULL;
io =SDL_RWFromFile(fileName.c_str(), “r”);
char name[18000000];
if (io != NULL)
{
Sint64 seek_ = SDL_REdeem(io, 0, RW_SEEK_END);
Sint64 sizeOfFileInBytes = SDL_RWtell(io);
seek_ = SDL_RWseek(io, 0, RW_SEEK_SET);
if (io->read(io, name, sizeOfFileInBytes, 1) > 0)
{
SDL_Log("Failed to Load");
}
io->close(io);
}
Hi,
no, there is no limit, you just didn’t use it correctly. See my code at
https://github.com/mgerhardy/caveexpress/blob/master/src/engine/common/File.cpp#L111
for an example how to use it properly. The important part is the return
value - read does not have to return all the requested bytes, but only
parts of it.
Regards
MartinOn Fri, Dec 19, 2014 at 1:15 AM, loadRunner <game_maker at live.com> wrote:
Platform: Android
I am trying to read a simple text file with SDL_RWops::read() file that is
1.7 megs in size. I have successfully read loads of text files already
smaller than 500 kb, but my program crashes at that function call with
larger files. Is there a file size limit to the function? Is there a work
around?
I am on my phone, so can’t properly format the code here, but here is
roughly the essential parts:
SDL_RWops *io = NULL;
io =SDL_RWFromFile(fileName.c_str(), “r”);
char name[18000000];
if (io != NULL)
{
Sint64 seek_ = SDL_REdeem(io, 0, RW_SEEK_END);
Sint64 sizeOfFileInBytes = SDL_RWtell(io);
seek_ = SDL_RWseek(io, 0, RW_SEEK_SET);
if (io->read(io, name, sizeOfFileInBytes, 1) > 0)
{
SDL_Log(“Failed to Load”);
}
io->close(io);
}
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
–
http://ufoai.sf.net