[physfs] PHYSFS_setWriteDir creates an empty file if the path its given does not exist

Markus Koschany apo at debian.org
Tue May 15 16:47:07 EDT 2018


Hello,

I have recently received a bug report for lincity-ng, a simcity-like
simulation game, which makes use of physfs. [1]

The code in lincity-ng is supposed to create a directory in the user's
home directory and store configuration data. In physfs 2.0.3 everything
works as expected and the directory is created if it doesn't already exist.

main.cpp

   81     // Set configuration directory
   82     //sprintf(writedir, "%s.%s", userdir, application);
   83     sprintf(writedir, "%s%s", userdir, application);
   84     if(!PHYSFS_setWriteDir(writedir)) {
   85         // try to create the directory
   86         char* mkdir = new char[strlen(application) + 2];
   87         sprintf(mkdir, "%s", application);
   88         if(!PHYSFS_setWriteDir(userdir) || !PHYSFS_mkdir(mkdir)) {
   89             std::ostringstream msg;
   90             msg << "Failed creating configuration directory '" <<
   91                 writedir << "': " << PHYSFS_getLastError();

My question is: Is this a regression/bug in physfs 3.0.1 or is it a
feature now? If it is the latter I would appreciate some comments how to
fix this issue in lincity-ng with physfs 3.0.1.

You can find the complete source code of lincity-ng here [2].

Thank you very much for your time.

Regards,

Markus


[1] https://bugs.debian.org/898483
[2] https://salsa.debian.org/games-team/lincity-ng

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 963 bytes
Desc: OpenPGP digital signature
URL: <http://icculus.org/pipermail/physfs/attachments/20180515/94583346/attachment.sig>


More information about the physfs mailing list