3.3 Extracting files

Since xad.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 pic.jpg from the archive test.rar, just use the following line:

 
CopyFile("test.rar/pic.jpg", "outputdir")

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

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

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

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

This, however, will be pretty slow because Hollywood's plugin interface currently doesn't have dedicated functions designed for optimized archive extraction. Thus, CopyFile() will need to scan the whole archive for every single file it needs to unpack instead of just unpacking files sequentially. It also has to buffer files completely in memory which means that you currently can't unpack huge files with CopyFile(). Thus, for maximum performance and scalability you should use xad.ExtractFile() to unpack files instead of CopyFile().


Show TOC