You can also modify zip archives by simply using functions from Hollywood's DOS library.
For example, to delete the file test.jpg
from the zip archive test.zip
, you
can just do the following:
DeleteFile("test.zip/test.jpg", {Adapter = "zip"}) |
Note that it's mandatory to pass the Adapter
tag to DeleteFile()
because zip.hwp
doesn't install a filesystem adapter even when setting the InstallAdapter
tag to True
(see above). Zip.hwp's filesystem adapter is only accessible by directly passing it to
a Hollywood function in the Adapter
tag.
It's also possible to rename files inside zip archives using Hollywood's Rename()
function. This can be done like that:
Rename("test.zip/oldname.txt", "newname.txt", {Adapter = "zip"}) |
Like above, you have to pass the Adapter
tag to Rename()
for this to work.
You can create directories inside zip archives like so:
MakeDirectory("test.zip/a_new_dir", {Adapter = "zip"}) |
Don't forget to pass "zip" in the Adapter
tag here as well.
New files inside zip archives can be created like this:
OpenFile(1, "test.zip/new_file", #MODE_WRITE) WriteLine("Hello World!") CloseFile(1) |
Or even shorter:
StringToFile("Hello World!", "test.zip/new_file") |
You can use user tags to specify a password and an encryption level as well:
StringToFile("Hello World!", "test.zip/new_file", {UserTags = {Password = "123456", Encryption = #ZIP_EM_AES_128}}) |
Note that when writing files to zip archives, existing files in the zip archive won't be deleted but the new files will be appended to the zip archive. Do note, however, that if the file to be written to a zip archive exists, it will be automatically overwritten so be careful.
It's even possible to copy files into zip archives using CopyFile()
. For example, you
could also do something like this:
CopyFile("testfile", "test.zip", {Adapter = "zip"}) |
The code above will store the file testfile
in the zip archive test.zip
.
Finally, you can change the attributes of files inside zip archives using Hollywood's
SetFileAttributes()
function or move files in and out of zip archives using Hollywood's
MoveFile()
function. Just pass the name of the file you want to modify and "zip"
in the Adapter
tag and it will work. It's really convenient and powerful!