List Archive

Thread

Thread Index

Message

From: Dieter Baron <dillo%danbala.tuwien.ac.at@localhost>
To: Sean Beck <seanmckaybeck%gmail.com@localhost>
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 <seanmckaybeck%gmail.com@localhost> 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:

dir1/subdir1/file1
dir2/file3
dir2/file2
dir1/subdir2/file1
dir1/subidr1/file2

  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.

yours,
dillo


On Fri, Jul 26, 2013 at 11:32 AM, Thomas Klausner <tk%giga.or.at@localhost> 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.
 Thomas


Made by MHonArc.