Don't fail enumeration if a directory isn't available in a given archive.
authorRyan C. Gordon <icculus@icculus.org>
Mon, 14 Aug 2017 14:05:06 -0400
changeset 1577 77b9eee5b834
parent 1576 b25da658b8ee
child 1578 59595a791451
Don't fail enumeration if a directory isn't available in a given archive.

That shouldn't be a fatal error, that's a normal case.
src/physfs.c
--- a/src/physfs.c	Mon Aug 14 13:57:57 2017 -0400
+++ b/src/physfs.c	Mon Aug 14 14:05:06 2017 -0400
@@ -2433,7 +2433,17 @@
 
             else if (verifyPath(i, &arcfname, 0))
             {
-                if ((!allowSymLinks) && (i->funcs->info.supportsSymlinks))
+                PHYSFS_Stat statbuf;
+                if (!i->funcs->stat(i->opaque, arcfname, &statbuf))
+                {
+                    if (currentErrorCode() == PHYSFS_ERR_NOT_FOUND)
+                        continue;  /* no such dir in this archive, skip it. */
+                } /* if */
+
+                if (statbuf.filetype != PHYSFS_FILETYPE_DIRECTORY)
+                    continue;  /* not a directory in this archive, skip it. */
+
+                else if ((!allowSymLinks) && (i->funcs->info.supportsSymlinks))
                 {
                     filterdata.dirhandle = i;
                     filterdata.arcfname = arcfname;
@@ -2446,7 +2456,7 @@
                         if (currentErrorCode() == PHYSFS_ERR_APP_CALLBACK)
                             PHYSFS_setErrorCode(filterdata.errcode);
                     } /* if */
-                } /* if */
+                } /* else if */
                 else
                 {
                     retval = i->funcs->enumerate(i->opaque, arcfname,