decompress (zlib) bytes

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

decompress (zlib) bytes

Post by asrael »

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: 475
Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA

Re: decompress (zlib) bytes

Post by SamuraiCrow »

Look into Virtual Files. It's just one extra step.
I'm on registered MorphOS using FlowStudio.
asrael
Posts: 31
Joined: Mon Jul 23, 2018 6:57 pm

Re: decompress (zlib) bytes

Post by asrael »

Hmm, not bad.
That should work, thanks.



Manfred
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: decompress (zlib) bytes

Post by airsoftsoftwair »

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: 31
Joined: Mon Jul 23, 2018 6:57 pm

Re: decompress (zlib) bytes

Post by asrael »

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