Skip to content

Commit

Permalink
Make PHYSFS_exists() work with mounts from PHYSFS_mountIo(io, NULL, ...)
Browse files Browse the repository at this point in the history
(Actually, from any mount function that accepts a bogus/NULL filename.)
  • Loading branch information
icculus committed Aug 14, 2017
1 parent 3b7ee39 commit cfe3f01
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/physfs.c
Expand Up @@ -2170,9 +2170,9 @@ int PHYSFS_delete(const char *_fname)
} /* PHYSFS_delete */


const char *PHYSFS_getRealDir(const char *_fname)
static DirHandle *getRealDirHandle(const char *_fname)
{
const char *retval = NULL;
DirHandle *retval = NULL;
char *fname = NULL;
size_t len;

Expand All @@ -2189,15 +2189,15 @@ const char *PHYSFS_getRealDir(const char *_fname)
char *arcfname = fname;
if (partOfMountPoint(i, arcfname))
{
retval = i->dirName;
retval = i;
break;
} /* if */
else if (verifyPath(i, &arcfname, 0))
{
PHYSFS_Stat statbuf;
if (i->funcs->stat(i->opaque, arcfname, &statbuf))
{
retval = i->dirName;
retval = i;
break;
} /* if */
} /* if */
Expand All @@ -2207,6 +2207,12 @@ const char *PHYSFS_getRealDir(const char *_fname)

__PHYSFS_smallFree(fname);
return retval;
} /* getRealDirHandle */

const char *PHYSFS_getRealDir(const char *fname)
{
DirHandle *dh = getRealDirHandle(fname);
return dh ? dh->dirName : NULL;
} /* PHYSFS_getRealDir */


Expand Down Expand Up @@ -2482,7 +2488,7 @@ void PHYSFS_enumerateFilesCallback(const char *fname,

int PHYSFS_exists(const char *fname)
{
return (PHYSFS_getRealDir(fname) != NULL);
return (getRealDirHandle(fname) != NULL);
} /* PHYSFS_exists */


Expand Down

0 comments on commit cfe3f01

Please sign in to comment.