From cfe3f0180b33aa7e7b5777493406c561092490da Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 14 Aug 2017 03:06:42 -0400 Subject: [PATCH] Make PHYSFS_exists() work with mounts from PHYSFS_mountIo(io, NULL, ...) (Actually, from any mount function that accepts a bogus/NULL filename.) --- src/physfs.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/physfs.c b/src/physfs.c index 5bea2079..caf6e19f 100644 --- a/src/physfs.c +++ b/src/physfs.c @@ -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; @@ -2189,7 +2189,7 @@ 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)) @@ -2197,7 +2197,7 @@ const char *PHYSFS_getRealDir(const char *_fname) PHYSFS_Stat statbuf; if (i->funcs->stat(i->opaque, arcfname, &statbuf)) { - retval = i->dirName; + retval = i; break; } /* if */ } /* if */ @@ -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 */ @@ -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 */