Skip to content

Commit

Permalink
PHYSFS_setWriteDir() shouldn't create an empty file if the dir doesn'…
Browse files Browse the repository at this point in the history
…t exist.
  • Loading branch information
icculus committed May 16, 2018
1 parent 15dd006 commit 8ce294a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/physfs.c
Expand Up @@ -879,13 +879,20 @@ static DirHandle *openDirectory(PHYSFS_Io *io, const char *d, int forWriting)

if (io == NULL)
{
/* file doesn't exist, etc? Just fail out. */
PHYSFS_Stat statbuf;
BAIL_IF_ERRPASS(!__PHYSFS_platformStat(d, &statbuf, 1), NULL);

/* DIR gets first shot (unlike the rest, it doesn't deal with files). */
retval = tryOpenDir(io, &__PHYSFS_Archiver_DIR, d, forWriting, &claimed);
if (retval || claimed)
return retval;
if (statbuf.filetype == PHYSFS_FILETYPE_DIRECTORY)
{
retval = tryOpenDir(io, &__PHYSFS_Archiver_DIR, d, forWriting, &claimed);
if (retval || claimed)
return retval;
} /* if */

io = __PHYSFS_createNativeIo(d, forWriting ? 'w' : 'r');
BAIL_IF_ERRPASS(!io, 0);
BAIL_IF_ERRPASS(!io, NULL);
created_io = 1;
} /* if */

Expand Down

0 comments on commit 8ce294a

Please sign in to comment.