zip: add some zip_resolve() calls, deal with DirTree-inserted parent dirs.
authorRyan C. Gordon <icculus@icculus.org>
Mon, 14 Aug 2017 16:24:19 -0400
changeset 1579 f8c1de3af573
parent 1578 59595a791451
child 1580 fe39971cb47c
zip: add some zip_resolve() calls, deal with DirTree-inserted parent dirs.
src/physfs_archiver_zip.c
--- a/src/physfs_archiver_zip.c	Mon Aug 14 14:06:43 2017 -0400
+++ b/src/physfs_archiver_zip.c	Mon Aug 14 16:24:19 2017 -0400
@@ -709,6 +709,7 @@
     } /* while */
 } /* zip_expand_symlink_path */
 
+
 static inline ZIPentry *zip_find_entry(ZIPinfo *info, const char *path)
 {
     return (ZIPentry *) __PHYSFS_DirTreeFind(&info->tree, path);
@@ -879,7 +880,11 @@
      */
     if (resolve_type != ZIP_RESOLVED)
     {
-        entry->resolved = ZIP_RESOLVING;
+        if (entry->tree.isdir)  /* an ancestor dir that DirTree filled in? */
+        {
+            entry->resolved = ZIP_DIRECTORY;
+            return 1;
+        } /* if */
 
         retval = zip_parse_local(io, entry);
         if (retval)
@@ -1548,6 +1553,9 @@
     } /* if */
 
     BAIL_IF_ERRPASS(!entry, NULL);
+
+    BAIL_IF_ERRPASS(!zip_resolve(info->io, info, entry), NULL);
+
     BAIL_IF(entry->tree.isdir, PHYSFS_ERR_NOT_A_FILE, NULL);
 
     retval = (PHYSFS_Io *) allocator.Malloc(sizeof (PHYSFS_Io));
@@ -1638,11 +1646,14 @@
 static int ZIP_stat(void *opaque, const char *filename, PHYSFS_Stat *stat)
 {
     ZIPinfo *info = (ZIPinfo *) opaque;
-    const ZIPentry *entry = zip_find_entry(info, filename);
+    ZIPentry *entry = zip_find_entry(info, filename);
 
     if (entry == NULL)
         return 0;
 
+    else if (!zip_resolve(info->io, info, entry))
+        return 0;
+
     else if (entry->resolved == ZIP_DIRECTORY)
     {
         stat->filesize = 0;