Skip to content

Commit

Permalink
zip: add some zip_resolve() calls, deal with DirTree-inserted parent …
Browse files Browse the repository at this point in the history
…dirs.
  • Loading branch information
icculus committed Aug 14, 2017
1 parent 395ea71 commit 0d1a73f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/physfs_archiver_zip.c
Expand Up @@ -709,6 +709,7 @@ static void zip_expand_symlink_path(char *path)
} /* while */
} /* zip_expand_symlink_path */


static inline ZIPentry *zip_find_entry(ZIPinfo *info, const char *path)
{
return (ZIPentry *) __PHYSFS_DirTreeFind(&info->tree, path);
Expand Down Expand Up @@ -879,7 +880,11 @@ static int zip_resolve(PHYSFS_Io *io, ZIPinfo *info, ZIPentry *entry)
*/
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)
Expand Down Expand Up @@ -1548,6 +1553,9 @@ static PHYSFS_Io *ZIP_openRead(void *opaque, const char *filename)
} /* 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));
Expand Down Expand Up @@ -1638,11 +1646,14 @@ static int ZIP_mkdir(void *opaque, const char *name)
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;
Expand Down

0 comments on commit 0d1a73f

Please sign in to comment.