haxe.zip.Uncompress not working for javascript?

253 views
Skip to first unread message

Nathan Hüsken

unread,
Feb 1, 2016, 8:54:34 AM2/1/16
to haxe...@googlegroups.com
Hey,

The documentation here says:
http://api.haxe.org/haxe/zip/Uncompress.html that uncompress is
available on all platforms.

But when I try to run haxe.zip.Reader.unzip from javascript, I get an
exception:

Uncompress.hx: Not implemented for this platform.

Is the documentation wrong?
Can I uncompress zips in javascript?

Thanks!
Nathan

clemos

unread,
Feb 1, 2016, 9:05:57 AM2/1/16
to haxe...@googlegroups.com
Hi,


BTW this whole haxe.zip.* vs format.zip.* vs _std.haxe.zip.* (vs format.tools.Inflate / Deflate, etc) APIs should be cleaned somehow.

++
Clément

Nathan

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Nathan Hüsken

unread,
Feb 1, 2016, 12:43:12 PM2/1/16
to haxe...@googlegroups.com
Hey,

Looking at:
https://github.com/HaxeFoundation/format/blob/master/format/zip/Reader.hx

I read:


#if haxe3

typedef Reader = haxe.zip.Reader;

#else
...


So it does not really make a difference. And If I try it out I get the
same error.

I can not find any implementation for javascript. Am I missing something?

Thanks!
Nathan

On 01.02.2016 15:05, clemos wrote:
> Hi,
>
> You should try using
> format: https://github.com/HaxeFoundation/format/blob/master/format/zip/Reader.hx
>
> BTW this whole haxe.zip.* vs format.zip.* vs _std.haxe.zip.* (vs
> format.tools.Inflate / Deflate, etc) APIs should be cleaned somehow.
>
> ++
> Clément
>
> On Mon, Feb 1, 2016 at 2:54 PM, Nathan Hüsken <nathan....@posteo.de
> <mailto:nathan....@posteo.de>> wrote:
>
> Hey,
>
> The documentation here says:
> http://api.haxe.org/haxe/zip/Uncompress.html that uncompress is
> available on all platforms.
>
> But when I try to run haxe.zip.Reader.unzip from javascript, I get an
> exception:
>
> Uncompress.hx: Not implemented for this platform.
>
> Is the documentation wrong?
> Can I uncompress zips in javascript?
>
> Thanks!
> Nathan
>
> --
> To post to this group haxe...@googlegroups.com
> <mailto:haxe...@googlegroups.com>

Justin L Mills

unread,
Feb 1, 2016, 8:44:53 PM2/1/16
to haxe...@googlegroups.com
I am sure I found it was not implemented in the past for Javascript only
c++ and neko but that could have changed.

I don't know anything about webworkers but something like this looks
portable maybe then make a request for MIT license from authors?

https://github.com/gildas-lormeau/zip.js/blob/master/WebContent/inflate.js

Not clear if it's structured quite the same as the "format" structures
but perhaps it would give inspiration. Or maybe just use it untyped.

underscorediscovery

unread,
Feb 1, 2016, 10:40:09 PM2/1/16
to Haxe
I use haxe.zip.Uncompress.run(compressed_bytes); without any trouble on the js target.

For input I use haxe.zip.Compress.run(source_bytes, 9);

I also found it odd that throw exists in the std lib but the above seemed to do what I needed.

Nathan Hüsken

unread,
Feb 2, 2016, 8:20:10 AM2/2/16
to haxe...@googlegroups.com
Hey,

Thanks for the tip. So you do:

haxe.zip.Uncompress.run(entry.data)

where entry is is part of an array, returned by haxe.zip.Reader.readZip?

If I do that, I get:

Uncaught Error: Invalid datahaxe_zip_InflateImpl.inflateLoop @
InflateImpl.hx:259haxe_zip_InflateImpl.readBytes @
InflateImpl.hx:151haxe_zip_InflateImpl.run @
InflateImpl.hx:368haxe_zip_Uncompress.run @
Uncompress.hx:41xlsx_XLSX.modifyXlsx @ XLSX.hx:119(anonymous function) @
AssignmentListDisplay.hx:103tink_core__$Callback_CallbackList_$Impl_$.invoke
@ Callback.hx:62tink_core_FutureTrigger.trigger @
Future.hx:164req.onreadystatechange @ Utils.hx:33

Idea on that?

Thanks!
Nathan

On 02.02.2016 04:40, underscorediscovery wrote:
> I use *haxe.zip.Uncompress.run(compressed_bytes); *without any trouble
> on the js target.
>
> For input I use *haxe.zip.Compress.run(source_bytes, 9);*
> *
> *
> <nathan....@posteo.de <javascript:>
> > <mailto:nathan....@posteo.de <javascript:>>> wrote:
> >
> > Hey,
> >
> > The documentation here says:
> > http://api.haxe.org/haxe/zip/Uncompress.html
> <http://api.haxe.org/haxe/zip/Uncompress.html> that uncompress is
> > available on all platforms.
> >
> > But when I try to run haxe.zip.Reader.unzip from javascript, I
> get an
> > exception:
> >
> > Uncompress.hx: Not implemented for this platform.
> >
> > Is the documentation wrong?
> > Can I uncompress zips in javascript?
> >
> > Thanks!
> > Nathan
> >
> > --
> > To post to this group haxe...@googlegroups.com <javascript:>
> > <mailto:haxe...@googlegroups.com <javascript:>>
> > http://groups.google.com/group/haxelang?hl=en
> <http://groups.google.com/group/haxelang?hl=en>
> > ---
> > You received this message because you are subscribed to the
> Google
> > Groups "Haxe" group.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
> >
> >
> > --
> > To post to this group haxe...@googlegroups.com <javascript:>
> > http://groups.google.com/group/haxelang?hl=en
> <http://groups.google.com/group/haxelang?hl=en>
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "Haxe" group.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.

Sven Bergström

unread,
Feb 2, 2016, 2:23:25 PM2/2/16
to haxe...@googlegroups.com
No I don't use any other zip api calls for what I need.
I think the end result is different, I'm merely compressing/uncompressing bytes, I don't make a zip file or entries from it or anything. 
I wanted to just mention the compress/uncompress part worked as I expected, and I found it odd the throw exists in standard lib too :)

For clarity, to compress/uncompress as I am:

var source_data: haxe.io.Bytes = ....; 
var compressed_data = haxe.zip.Compress.run(
source_data, 9);

...

var source_data = haxe.zip.Uncompress.run(compressed_data);


You received this message because you are subscribed to a topic in the Google Groups "Haxe" group.

Nathan Hüsken

unread,
Feb 2, 2016, 5:48:00 PM2/2/16
to haxe...@googlegroups.com
Ok, thanks.

I converted my zip files now to use no compression. Works for now, but
being able to uncompress would be nice.

Best Regards and Thanks!
Nathan

Daniel Uranga

unread,
Feb 4, 2016, 4:17:30 PM2/4/16
to haxe...@googlegroups.com
This one https://github.com/nodeca/pako looks really nice. Maybe using
externs for that would be a better solution.

Nathan Hüsken

unread,
Feb 4, 2016, 5:10:44 PM2/4/16
to haxe...@googlegroups.com
Thanks for the link. I will try it.
Reply all
Reply to author
Forward
0 new messages