Inflating zlib compresed data

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
daryl
Posts: 47
Joined: Mon Apr 29, 2013 11:43 pm

Inflating zlib compresed data

Post by daryl » Tue Jun 11, 2013 12:11 am

Hi Folks,

I've been digging around the documentation trying to find an answer, without any success, so I am hoping someone here can lend their expertise. I need to uncompress some zlib compressed data in a container. I've tried using the decompress function, but I get an error about the data not being compressed. It is my understanding that the decompress function is meant to work on gzipped data, and that although both gzip and zlib use the same compressed data format, they have different
trailers and headers around the data (see RFC's 1950, 1951, and 1952), but I am certainly no expert on compression formats.

I am hoping someone here can clarify if decompress is supposed to also works with zlib compressed data, or if there is another way to do this in LiveCode.

Any help would be much appreciated.

Thanks,

Daryl

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Inflating zlib compresed data

Post by mwieder » Tue Jun 11, 2013 12:55 am

What platform? Zip and gzip have various different methods they can use to compress data, and I think the built-in compress and decompress methods use just one.
If the revZipXXX functions don't do what you want, you can always resort to what I do in this situation: just use the shell command

Code: Select all

ask file "Find the zipped file"
if it is not empty then
  put it into tPathToFile
  put shell("unzip" && tPathToFile) into tResult
  if tResult is not empty then
    answer tResult
  end if
end if

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Inflating zlib compresed data

Post by mwieder » Tue Jun 11, 2013 12:56 am

Also note that if your zipped file contains a directory structure, the built-in commands won't unzip it properly - you have to use shell in that case.

daryl
Posts: 47
Joined: Mon Apr 29, 2013 11:43 pm

Re: Inflating zlib compresed data

Post by daryl » Tue Jun 11, 2013 1:00 am

Hi mwieder,

Thanks for your reply I will have to look into the revZipXXX functions, and thanks for the shell code example, I was starting to think I might have to do something like that, but wasn't sure how it's done in LiveCode. Hopefully the revZip functions will have what I need. Thanks again.

Regards,

Daryl

Post Reply