Wrapping DEFLATED data
Posted: Sat Jun 15, 2013 12:57 am
Hi Folks,
I have recently posted a question to the beginners forum titled "Inflating ZIP Deflated data string ", which I won't repeat here, but I have another angle I am trying on this problem, and was hoping maybe someone with more experience might be able to help. The issue is this: I have to read some deflated compressed data from a network socket and then inflate it back to the original. I discovered that LiveCode has the revZip functions to deal with zipped data, but they appear to only work on file archives. So created a file archive, added my data using the revZipAddUncompressedItemWithData function as I didn't want the data compressed yet again, closed the archive, opened it and used the revZipExtractItemToVariable function to get the data back from the archive and into a variable. That all worked, except the data was still deflated.
So having read the compress definition in the dictionary and about how to wrap deflated data with a header and a trailer, I thought I would try that, and I had partial success. That is, I can write my wrapped data to file and running the unix "file" command it tells me it's "file.gz: gzip compressed data, from Unix" but if I try to gunzip it I get "gzip: gzip.gz: invalid compressed data--format violated". I have done a hex dump to make sure the file has the 10 byte header and 8 byte trailer with my data in the middle as described in the dictionary and it looks like what I expect.
It is my understanding that both zip and gzip use the DEFLATE algorithm to compress data, and that the difference between the two is in the header and footer, so I am not sure what I'm doing wrong, as my data is deflated data, and I can read the same data and deflate it by using a perl script and their Compress::Zlib module.
Does anyone know if there are any plans on extending the revZip functions to include deflating a deflated binary string from a variable?
Any help, thoughts, pointers to documentation, etc. would be greatly appreciated.
Thanks,
Daryl
I have recently posted a question to the beginners forum titled "Inflating ZIP Deflated data string ", which I won't repeat here, but I have another angle I am trying on this problem, and was hoping maybe someone with more experience might be able to help. The issue is this: I have to read some deflated compressed data from a network socket and then inflate it back to the original. I discovered that LiveCode has the revZip functions to deal with zipped data, but they appear to only work on file archives. So created a file archive, added my data using the revZipAddUncompressedItemWithData function as I didn't want the data compressed yet again, closed the archive, opened it and used the revZipExtractItemToVariable function to get the data back from the archive and into a variable. That all worked, except the data was still deflated.
So having read the compress definition in the dictionary and about how to wrap deflated data with a header and a trailer, I thought I would try that, and I had partial success. That is, I can write my wrapped data to file and running the unix "file" command it tells me it's "file.gz: gzip compressed data, from Unix" but if I try to gunzip it I get "gzip: gzip.gz: invalid compressed data--format violated". I have done a hex dump to make sure the file has the 10 byte header and 8 byte trailer with my data in the middle as described in the dictionary and it looks like what I expect.
It is my understanding that both zip and gzip use the DEFLATE algorithm to compress data, and that the difference between the two is in the header and footer, so I am not sure what I'm doing wrong, as my data is deflated data, and I can read the same data and deflate it by using a perl script and their Compress::Zlib module.
Does anyone know if there are any plans on extending the revZip functions to include deflating a deflated binary string from a variable?
Any help, thoughts, pointers to documentation, etc. would be greatly appreciated.
Thanks,
Daryl