List Archive


Thread Index


From: Dieter Baron <>
To: Sean Beck <>
Subject: Re: Iterate through directory in zip archive
Date: Sat, 27 Jul 2013 10:15:16 +0200

On Jul 26, 2013, at 20:28 , Sean Beck <> wrote:

But I don't know the specific names of the directories: just the base dir.

  Zip archvies don't contain a proper directory structure, just a list of files with complete path names, stored in no particular order.  For example:


  libzip let's you iterate over this list:

zip_int64_t num_entries = zip_get_num_entries(za, 0);

for (zip_uint64_t i = 0; i < (zip_uint64_t)num_entries; i++) {
const char *name = zip_get_name(za, i, 0);

// use name

  You can split name on '/' into path comonents and filter those you're interested in, or build your own directory structure.


On Fri, Jul 26, 2013 at 11:32 AM, Thomas Klausner <> wrote:
On Fri, Jul 26, 2013 at 10:29:15AM -0600, Sean Beck wrote:
> If I want to iterate over a directory in the zip archive would I get a
> zip_file* for the dir then.....I don't know?

You can only iterate over all the files in the archive.

I guess the best way to do what you want is to iterate over all files
and compare the start of the file names with the name of the directory
you're interested in.

Made by MHonArc.