[physfs] Renaming support

Sik the hedgehog sik.the.hedgehog at gmail.com
Wed Jul 30 07:23:42 EDT 2014


So I noticed PhysicsFS doesn't allow renaming files. In fact, it seems
this is intended:
http://web.archiveorange.com/archive/v/jy9nRkPeQ5zXk0Y2sNPb

Well yeah, I need to rename files. The reason is simple: I need to
write configuration data and such, and the problem is that if
something goes wrong while writing, the file will be corrupt and the
old data will be lost, leaving it completely unusable. My idea was to
instead write to a temporary file, then delete the original and rename
the temporary file to its final location. Problem is, PhysicsFS
doesn't allow this, and copying-and-delete can be troublesome (in
particular, both the temporary and original files could be potentially
corrupt, so I have no option but to parse both files, and since in one
case it's an INI file that one could even become undetectable if some
data is lost).

In other words, I need either PhysicsFS to allow renaming, or to do
that back-up job for me (either solution will do).

PS: yes, I'm aware that the standard library has rename() so I could
just try to get the real path and rename it myself, but I'd rather not
have to deal with the mess that's codepages (rename() on Windows
doesn't use Unicode filenames).


More information about the physfs mailing list