add empty directory using zipfile?

Ben Finney bignose-hates-spam at and-zip-does-too.com.au
Thu Jun 26 06:50:50 CEST 2003


On Thu, 26 Jun 2003 04:31:37 GMT, JanC wrote:
> Tung Wai Yip <tungwaiyip at yahoo.com> schreef:
>> Can I add empty directory using zipfile? When I try to add a
>> directory it complains that it is not a file.
> 
> ZIP files can't contain directories, only files and the paths to those 
> files.  A workaround might be to put an empty file in the directory.

A better solution might be to use tar (or cpio) for archiving, since
they can add directories as well as files, and can also preserve file
permissions from Unix filesystems.

You then get the benefit of choosing whatever compression method you
like for the resultant archive.  gzip and bzip2 both offer superior
compression to the built-in compression for Zip.

-- 
 \       "Timid men prefer the calm of despotism to the boisterous sea |
  `\                                 of liberty."  -- Thomas Jefferson |
_o__)                                                                  |
http://bignose.squidly.org/ 9CFE12B0 791A4267 887F520C B7AC2E51 BD41714B




More information about the Python-list mailing list