3.2 Zip archives as directories

When setting the InstallAdapter tag to True, the zip plugin hooks into Hollywood's directory handler to make Hollywood believe that zip archives are normal directories. This allows you to iterate over all files and directories inside a zip archive using normal functions from Hollywood's DOS library.

For example, to iterate over all files and directory inside a file named test.zip you could use the following code:

OpenDirectory(1, "test.zip")
Local e = NextDirectoryEntry(1)
While e <> Nil
    e = NextDirectoryEntry(1)

If you don't want to start from the root directory inside test.zip, you can also conveniently start from a subdirectory by just pretend that test.zip is a directory, e.g. to access a subdirectory named files inside test.zip just do the following:

OpenDirectory(1, "test.zip/files")

Finally, it is also possible to recursively iterate through all files and directories inside a zip archive. Here is a function which does that:

Function p_DumpZip(d$, idt)
    Local id = OpenDirectory(Nil, d$)
    Local e = NextDirectoryEntry(id)
    While e <> Nil
        If e.Type = #DOSTYPE_DIRECTORY
            DebugPrint(RepeatStr(" ", idt) .. "+", e.name)
            p_DumpZip(FullPath(d$, e.name), idt + 4)
            DebugPrint(RepeatStr(" ", idt) .. "",e.name,e.size,e.time)
        e = NextDirectoryEntry(id)

To dump the contents of a zip archive, just call this function like that:

p_DumpZip("test.zip", 0)

It will then print a nice tree of the zip archive's contents.

Show TOC