When using the high-level interface of the plugin, it's possible to use normal Hollywood functions to deal with files and directories inside archives. The plugin will also make Hollywood believe that archives 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
DebugPrint(e.name)
e = NextDirectoryEntry(1)
Wend
CloseDirectory(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)
Else
DebugPrint(RepeatStr(" ", idt) .. "",e.name,e.size,e.time)
EndIf
e = NextDirectoryEntry(id)
Wend
CloseDirectory(id)
EndFunction
|
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.