diff --git a/archivers/zip.c b/archivers/zip.c index 5c9ae2f..e8f7620 100644 --- a/archivers/zip.c +++ b/archivers/zip.c @@ -1241,10 +1241,9 @@ static LinkedStringList *ZIP_enumerateFiles(DirHandle *h, static int ZIP_exists(DirHandle *h, const char *name) { 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); + int retval = (zip_find_start_of_dir(info, name, 1) != -1); + if (!retval) /* not a dir? Look for a regular file entry... */ + retval = (zip_find_entry(info, name) != NULL); return(retval); } /* ZIP_exists */ @@ -1253,9 +1252,17 @@ static PHYSFS_sint64 ZIP_getLastModTime(DirHandle *h, const char *name, int *fileExists) { - ZIPentry *entry = zip_find_entry((ZIPinfo *) h->opaque, name); + ZIPinfo *info = (ZIPinfo *) h->opaque; + ZIPentry *entry; + + if (zip_find_start_of_dir(info, name, 1) != -1) + { + *fileExists = 1; + return(1); /* Best I can do for a dir... */ + } /* if */ + + entry = zip_find_entry(info, name); *fileExists = (entry != NULL); - /* !!! FIXME: Fails for directories. */ BAIL_IF_MACRO(entry == NULL, NULL, -1); return(entry->last_mod_time); } /* ZIP_getLastModTime */