There are several ways of using this plugin: There is a low-level library interface which provides dedicated functions for dealing with zip archives, e.g. zip.OpenArchive() to open an archive and zip.ExtractFile() to extract a file. The low-level interface is a bit more difficult to use than the high-level interface but offers the greatest level of control over zip archives and also the best performance.
Additionally, zip.hwp has a high-level interface which allows your script to deal with
zip archives without having to learn any kind of new APIs. Instead, you can just use normal
Hollywood functions to access zip archives. There are two ways of using the high-level interface:
You can either activate the plugin globally by setting the InstallAdapter
tag to True
when
@REQUIRE-ing
it. To do this, simply put the following preprocessor command at the top of your
script:
@REQUIRE "zip", {InstallAdapter = True} |
If you activate the high-level interface via @REQUIRE
, it will become globally available
and all ensuing commands that deal with files will support the opening of files from zip archive
sources. For example, you could do something like this then:
LoadBrush(1, "test.zip/testpicture.jpg") |
If you only need to open very few files from zip archive sources, you can also choose to
not activate the high-level interface globally by omitting the InstallAdapter
tag on @REQUIRE
and
simply use the Adapter
tag offered by most Hollywood commands to tell the respective Hollywood
command to open the file using the zip.hwp plugin. Here is an example:
LoadBrush(1, "test.zip/testpicture.jpg", {Adapter = "zip"}) |
By using the Adapter
tag, LoadBrush()
is told to open the specified file using
the specified adapter, which is "zip" in our case. Thus, the Adapter
tag
allows you to use this plugin even without having installed a global file adapter for
it first.
The same is true for Hollywood functions dealing with directories. Once the high-level interface
has been activated by setting InstallAdapter
to True
, it is possible to do things like
the following:
OpenDirectory(1, "test.zip") |
You could then iterate over all files and directories in test.zip
. If you haven't
activated the global adapter for zip.hwp, then just use the local Adapter
like above, e.g.
OpenDirectory(1, "test.zip", {Adapter = "zip"}) |
See the next chapter for more details on treating zip archives as directories.