ZIP_exists() now works with directories.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 21 Aug 2002 22:33:30 +0000
changeset 470 27119d6e5d40
parent 469 e41c2b9bf868
child 471 80ba173a3125
ZIP_exists() now works with directories.
archivers/zip.c
--- a/archivers/zip.c	Wed Aug 21 04:39:08 2002 +0000
+++ b/archivers/zip.c	Wed Aug 21 22:33:30 2002 +0000
@@ -1169,7 +1169,6 @@
                 rc = 1;
             else 
             {
-                
                 if (stop_on_first_find) /* Just checking dir's existance? */
                     return(middle);
 
@@ -1241,8 +1240,12 @@
 
 static int ZIP_exists(DirHandle *h, const char *name)
 {
-    ZIPentry *entry = zip_find_entry((ZIPinfo *) h->opaque, name);
-    return(entry != NULL);
+    ZIPinfo *info = (ZIPinfo *) h->opaque;
+    int retval = (zip_find_entry(info, name) != NULL);
+/* !!! FIXME: this would be faster the other way, I think: dirs first. */
+    if (!retval)  /* might be a directory... */
+        retval = (zip_find_start_of_dir(info, name, 1) != -1);
+    return(retval);
 } /* ZIP_exists */
 
 
@@ -1252,6 +1255,7 @@
 {
     ZIPentry *entry = zip_find_entry((ZIPinfo *) h->opaque, name);
     *fileExists = (entry != NULL);
+    /* !!! FIXME: Fails for directories. */
     BAIL_IF_MACRO(entry == NULL, NULL, -1);
     return(entry->last_mod_time);
 } /* ZIP_getLastModTime */