Interesting. Maybe the behavior is actually only half a bug.
I looked up the problem in the manual again, but it doesn't seem to be mentioned directly.
However, section 7.9 (Loaders and adapters) describes the process of how loaders are used (Hollywood will ask all plugins whether they want to handle the file).
That explains the effect to some extent, but I would like to see a comment in the manual or a more informative error message.
Extract file content into string without creating a flie
Re: Extract file content into string without creating a flie
It seems DeleteFile does have the ability to use the zip plugin, just not via InstallAdapter. Adapter = "zip" works
Here in this example there is no zip.defaultpassword set, and no password in the argument of DeleteFile, but it still is able to access the archive and delete files within it. The password must be left in memory and used by the zip plugin also for DeleteFile. If running a script with only the DeleteFile command I am not able to delete files in the archive.
off topic: I was not aware of this thing about zip archives that you could have both encrypyted and unencrypted files in the same archive.
Here in this example there is no zip.defaultpassword set, and no password in the argument of DeleteFile, but it still is able to access the archive and delete files within it. The password must be left in memory and used by the zip plugin also for DeleteFile. If running a script with only the DeleteFile command I am not able to delete files in the archive.
Code: Select all
@REQUIRE "zip", {Link = True}
secretfile$ = DefineVirtualFileFromString("This\nis\nthe\nvery\nsecret\nmessage", "secretmessage.data")
secretfile2$ = DefineVirtualFileFromString("This\nis\nthe\nsecond\nsecret\nmessage", "secretmessage2.data")
zip.OpenArchive(1, "secret.zip", #MODE_WRITE)
zip.AddFile(1, secretfile$, {Encryption = #ZIP_EM_AES_128, Password = "test1234"})
zip.AddFile(1, secretfile2$, {Encryption = #ZIP_EM_AES_128, Password = "test1234"})
zip.CloseArchive(1)
UndefineVirtualStringFile(secretfile$)
UndefineVirtualStringFile(secretfile2$)
NPrint("ZIP created with 2 files")
OpenFile(1, "secret.zip/secretmessage.data", #MODE_READ, {Adapter="zip", UserTags = {Password = "test1234"}})
While Not Eof(1) Do NPrint(ReadLine(1))
CloseFile(1)
NPrint("")
OpenFile(1, "secret.zip/secretmessage2.data", #MODE_READ, {Adapter="zip", UserTags = {Password = "test1234"}})
While Not Eof(1) Do NPrint(ReadLine(1))
CloseFile(1)
WaitLeftMouse
DeleteFile("secret.zip/secretmessage.data", {Adapter="zip"})
- airsoftsoftwair
- Posts: 5830
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Extract file content into string without creating a flie
Yup, as documented in the manual:
(source)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
The reason why this code doesn't work...
Code: Select all
DeleteFile("serverconfig.zip",{force=True})
I agree that all this is somewhat confusing but the file system handler stuff is quite complex and can do lots of magic but admittedly it sometimes also overcomplicates very simple things