decompress (zlib) bytes

Discuss any general programming issues here
Post Reply
asrael
Posts: 20
Joined: Mon Jul 23, 2018 6:57 pm

decompress (zlib) bytes

Post by asrael » Mon Jul 23, 2018 8:03 pm

Hi.

I've looked around a bit, but I couldn't find a way to decompress an array of bytes.
The Zip and XAD plugins only allow, also the CompressFile/DecompressFile functions only work on files.

Am I missing something?


Cheers,
Manfred

SamuraiCrow
Posts: 171
Joined: Fri May 15, 2015 5:15 pm
Location: Ft. Collins, Colorado USA

Re: decompress (zlib) bytes

Post by SamuraiCrow » Mon Jul 23, 2018 9:12 pm

Look into Virtual Files. It's just one extra step.

asrael
Posts: 20
Joined: Mon Jul 23, 2018 6:57 pm

Re: decompress (zlib) bytes

Post by asrael » Mon Jul 23, 2018 9:19 pm

Hmm, not bad.
That should work, thanks.



Manfred

User avatar
airsoftsoftwair
Posts: 2558
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany
Contact:

Re: decompress (zlib) bytes

Post by airsoftsoftwair » Tue Jul 24, 2018 12:57 pm

Keep in mind that both CompressFile() and DecompressFile() use a custom format so for raw zlib compressed bytes you'd have to imitate this custom format. I think there is a "HWPK" identifier, then 4 reserved bytes, and then the raw zlib compressed bytes. So by composing your virtual file like this you should be able to decompress raw bytes with DecompressFile():

Code: Select all

f$ = "HWPK" .. "\0\0\0\0" .. rawbytes$

asrael
Posts: 20
Joined: Mon Jul 23, 2018 6:57 pm

Re: decompress (zlib) bytes

Post by asrael » Tue Jul 24, 2018 5:25 pm

Ah, OK, thanks for this pointer.
I was thinking that the virtual files also work with the ZIP or XAD plugin.
But if I don't need a plugin it's even better.


Manfred

Post Reply