3.6 Creating zip archives

You can create new zip archives by using the zip.OpenArchive(), zip.AddFile(), and zip.CloseArchive() functions. The following code shows how to create a new zip archive named test.zip that contains the file testpicture.jpg:

 
zip.OpenArchive(1, "test.zip", #MODE_WRITE)
zip.AddFile(1, "testpicture.jpg")
zip.CloseArchive(1)

Note that zip.AddFile() does not immediately compress the file and write it to the archive. Instead, files are first collected and they are not compressed and written to the archive before you call zip.CloseArchive(). This is why closing an archive can take quite some time. There is also the possibility to pass a callback function which is invoked by zip.CloseArchive() from time to time so that you can update a status bar or something.


Show TOC