I'm trying to unpack zip archive in Dlang, but all methods what im tried isnt work.
I'm tried to:
auto archive = "/var/cache/dpm/packages/"~packagename~"/"~packagename~".zip"; auto zip = new ZipArchive(read(archive)); writeln(read(archive));
Excepted to get what archive contains, but get only many numbers.(You can see it on screenshot)
What is happens
After this, i tried to
readText instead of read because i see something like this when tried to read file with read and not readText, but it gives me error:
tf.d(1556): Invalid UTF-8 sequence (at index 1)
Where is my error?
Thanks for your help!
What you are seeing is the default output of a
ubyte array. It's a list of bytes, printed in decimal form.
read(archive) gives you the ubytes in the file. Nothing else. You are reading the file twice, the first time creating an archive out of it (which succeeds), and the second time reading it into a
ubyte array and printing that.
If you want the zip contents, you have to use the
ZipArchive api to do it. Looks like that would be
See the documentation for
ZipArchive, and an example how to use it here: https://dlang.org/phobos/std_zip.html