cpp.zip.uncompress

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

cpp.zip.uncompress

Philippe Riou
Hi lads,

I'm running on iphone with hxcpp. I have this swf I would very much like
to unzip using zlib. To do this, I use the
haxe.cpp.zip.uncompress.run(bytes, bufsize) method. The swf is produce
with flash 10.

It's working well as long as I set a large size for bufsize (Let's say
two times the size of the swf). In fact my problem appears if  bufsize
is not big enough to fit the entire uncompressed file.

In the Run method, there's a loop. My problem appears if inflate_buffer
is called more than once. I've tried all the flush mode available but
nothing changes. Do you have any clues what that is?

Regards.
Philippe

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

RE: cpp.zip.uncompress

luca deltodesco
Just don't set a bufsize? aka. uncompress.run(bytes)

> Date: Sat, 2 Jul 2011 19:34:36 +0200

> From: [hidden email]
> To: [hidden email]
> Subject: [haXe] cpp.zip.uncompress
>
> Hi lads,
>
> I'm running on iphone with hxcpp. I have this swf I would very much like
> to unzip using zlib. To do this, I use the
> haxe.cpp.zip.uncompress.run(bytes, bufsize) method. The swf is produce
> with flash 10.
>
> It's working well as long as I set a large size for bufsize (Let's say
> two times the size of the swf). In fact my problem appears if bufsize
> is not big enough to fit the entire uncompressed file.
>
> In the Run method, there's a loop. My problem appears if inflate_buffer
> is called more than once. I've tried all the flush mode available but
> nothing changes. Do you have any clues what that is?
>
> Regards.
> Philippe
>
> --
> haXe - an open source web programming language
> http://haxe.org

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: cpp.zip.uncompress

Philippe Riou
Yes, I did. If you don't set a buffer size, it defaults to 64k. Which leads to issue unless the uncompressed file fits in 64k...

I quite don't understand the problem, the code seems correct to me and matches the zlib samples.

Philippe

Le 03/07/2011 11:50, luca deltodesco a écrit :
Just don't set a bufsize? aka. uncompress.run(bytes)

> Date: Sat, 2 Jul 2011 19:34:36 +0200
> From: [hidden email]
> To: [hidden email]
> Subject: [haXe] cpp.zip.uncompress
>
> Hi lads,
>
> I'm running on iphone with hxcpp. I have this swf I would very much like
> to unzip using zlib. To do this, I use the
> haxe.cpp.zip.uncompress.run(bytes, bufsize) method. The swf is produce
> with flash 10.
>
> It's working well as long as I set a large size for bufsize (Let's say
> two times the size of the swf). In fact my problem appears if bufsize
> is not big enough to fit the entire uncompressed file.
>
> In the Run method, there's a loop. My problem appears if inflate_buffer
> is called more than once. I've tried all the flush mode available but
> nothing changes. Do you have any clues what that is?
>
> Regards.
> Philippe
>
> --
> haXe - an open source web programming language
> http://haxe.org



--

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: cpp.zip.uncompress

Philippe Riou
Ok found. The bug was coming from hxcpp. In the runtime libraries, in ZLib.cpp, a pointer should be incremented but is not :

line 207 & 208 should be :
z->next_in = (Bytef*)(buffer_data(src_buf) + val_int(srcpos));
z->next_out = (Bytef*)(buffer_data(dst_buf) + val_int(dstpos));

Hope this helps,
Philippe

Le 03/07/2011 11:58, Philippe Riou a écrit :
Yes, I did. If you don't set a buffer size, it defaults to 64k. Which leads to issue unless the uncompressed file fits in 64k...

I quite don't understand the problem, the code seems correct to me and matches the zlib samples.

Philippe

Le 03/07/2011 11:50, luca deltodesco a écrit :
Just don't set a bufsize? aka. uncompress.run(bytes)

> Date: Sat, 2 Jul 2011 19:34:36 +0200
> From: [hidden email]
> To: [hidden email]
> Subject: [haXe] cpp.zip.uncompress
>
> Hi lads,
>
> I'm running on iphone with hxcpp. I have this swf I would very much like
> to unzip using zlib. To do this, I use the
> haxe.cpp.zip.uncompress.run(bytes, bufsize) method. The swf is produce
> with flash 10.
>
> It's working well as long as I set a large size for bufsize (Let's say
> two times the size of the swf). In fact my problem appears if bufsize
> is not big enough to fit the entire uncompressed file.
>
> In the Run method, there's a loop. My problem appears if inflate_buffer
> is called more than once. I've tried all the flush mode available but
> nothing changes. Do you have any clues what that is?
>
> Regards.
> Philippe
>
> --
> haXe - an open source web programming language
> http://haxe.org



--



--

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: cpp.zip.uncompress

Gamehaxe
Nice one - thanks for the fix.

Hugh

--
haXe - an open source web programming language
http://haxe.org