3.2 Archives as directories

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

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

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

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

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

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

Function p_DumpArchive(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_DumpArchive(FullPath(d$, e.name), idt + 4)
            DebugPrint(RepeatStr(" ", idt) .. "",e.name,e.size,e.time)
        e = NextDirectoryEntry(id)

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

p_DumpArchive("test.rar", 0)

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

Show TOC