[physfs] Seeking to end of file

Patrice Mandin mandin.patrice at orange.fr
Wed Apr 28 12:33:10 EDT 2010


In my applications I use the following code to get the length of file
(this is with using SDL_RWops, but the concept is the same for most
similar API):

SDL_RWseek(src, 0, RW_SEEK_END);
length = SDL_RWtell(src);

Unfortunately, with physfs, the RW_SEEK_END operation fails (but should
succeed from my pov), depending on the underlying archiver backend:

archiver_grp.c, archiver_hog.c, archiver_iso9660.c, archiver_mvl.c,
archiver_qpak.c all fails because of:

BAIL_IF_MACRO(offset >= entry->size, ERR_PAST_EOF, 0);

Only 2 backends may succeed:

BAIL_IF_MACRO(offset > file->item->Size, ERR_PAST_EOF, 0);

BAIL_IF_MACRO(offset > entry->uncompressed_size, ERR_PAST_EOF, 0);

Patrice Mandin
WWW: http://pmandin.atari.org/
Programmeur Linux, Atari
Spécialité: Développement, jeux

More information about the physfs mailing list