deciding what is a dir (folder) in a zip file

Jim jhefferon at
Thu Nov 16 14:48:12 CET 2006


I'm trying to read .zip files and drop from the listing those files
that are directories.  I'm using the zipfile module.

Does anyone know how I can I tell which files in the .zip are
directories?  I have looked around the net for the information but I
cannot make it out: the pkzip specification hints that it is in the
"external file attribute" but also hints that it is dependent on the
platform on which the .zip was made (I get .zips from lots of
platforms).  The info-zip mailing list is unfortunately swamped by
spam, so I can't ask there.  Googling has increased my suspicion that
it is not just a matter of seeing if the file name ends in '/' and that
the relevant external file attribute seems to have different values for
people from different platforms, so just experimenting on my platform
doesn't seem to be a safe solution.

(I could os.system("unzip "+fn) and search the disk for directories but
I'd rather not, for reasons I won't list.)

I'd be grateful for any help,

More information about the Python-list mailing list