[physfs] Does PHYSFS_close really return 0 on error?
Ryan C. Gordon
icculus at icculus.org
Sun Sep 30 00:24:59 EDT 2007
> So, I have a function that wraps the open/close functions and keeps a tally
> of succesful opens and closes (according to the return values for those
> functions. 0 = failure for closing a file.) The tally is always equal! For
> each successfully opened file there is one corresponding succesful file
> closing. I have a little thing to output an error message if the return
> value of PHYFS_close(file) is 0, but it *never* shows up! This seems to
> indicate that there should really be no files open inside the .zip, and yet
> the call to remove it from the search path fails because there are.
Is the code available anywhere? It's worth checking for silly things like:
if (PHYSFS_close(x) == 0); // whoops, that semicolon is bad!
opened_files--; // always subtracts, no matter the retval...
It could be a bug in PhysicsFS, of course, but it's hard to say from
here. It isn't something that's been reported before, as far as I know.
> p.s. And the solution does not include having my files named differently.
> That's not an option (I'm not the one who named the files, and they must
> remain as they are)
You can certainly use it that way, but if that's done to work around a
PhysicsFS limitation, you can try PHYSFS_mount() in the 1.1 branch, so
you can have multiple archives with the same file names that don't overlap:
So if a.zip has file.txt, and so does b.zip, you might "mount" them at
"/one" and "/two" respectively, and then open files with
PHYSFS_openRead("/one/file.txt") and PHYSFS_openRead("/two/file.txt").
...whatever works best for your needs, of course.
--ryan.
More information about the physfs
mailing list