3.3 Extracting files

Since zip.hwp hooks into Hollywood's file handler when using the high-level interface, extracting files is just a matter of using Hollywood's CopyFile() function on the file you wish to extract. For example, to extract a file named testpicture.jpg from test.zip, just use the following line:

 
CopyFile("test.zip/testpicture.jpg", "outputdir")

If the zip archive is password-protected, you can pass the password to zip.hwp using the new user tags mechanism introduced in Hollywood 10. For example, if test.zip uses the password "123456", you could pass that password to zip.hwp like this:

 
CopyFile("test.zip/pic.jpg", "out", {UserTags = {Password = "123456")})

Since CopyFile() can also copy whole directories including all subdirectories and because zip.hwp hooks into Hollywood's directory handler as well, it is even possible to extract a whole archive using CopyFile(), like this:

 
CopyFile("test.zip", "outputdir")

You can also open files directly from zip archives because zip.hwp hooks into Hollywood's file handler. For example, you could do this to print all lines of test.txt stored in test.zip:

 
OpenFile(1, "test.zip/test.txt")
While Not Eof(1) Do DebugPrint(ReadLine(1))
CloseFile(1)

All Hollywood functions that deal with files support opening files from zip archives if zip.hwp's file adapter has been enabled. So you could also load images and other data files directly from a zip archive like this:

 
LoadBrush(1, "test.zip/test.jpg")


Show TOC