Open mikkelmr opened 5 years ago
I don't think it ever worked actually, it was a run-time error instead. Good news is that I actually have a somewhat working haxe.zip.Uncompress
for nodejs. Now I just need to find some time to finish/clean it up and add to the repo.
package haxe.zip;
import js.node.Buffer;
import js.node.Zlib;
class Uncompress {
final windowBits:Null<Int>;
public function new( ?windowBits : Int ) {
this.windowBits = windowBits;
}
public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } {
var src = js.node.Buffer.hxFromBytes(src).slice(srcPos);
var dst = js.node.Buffer.hxFromBytes(dst);
var res = cast Zlib.inflateRawSync(src, cast {info: true, /* windowBits: windowBits */});
var engine = res.engine;
var res:Buffer = res.buffer;
dst.set(res, dstPos);
return {done: true, read: engine.bytesRead, write: res.byteLength};
}
public function setFlushMode( f : FlushMode ) {
}
public function close() {
}
public static function run( src : haxe.io.Bytes, ?bufsize : Int ) : haxe.io.Bytes {
var buffer = js.node.Zlib.inflateSync(js.node.Buffer.hxFromBytes(src),bufsize == null ? {} : {chunkSize : bufsize});
return buffer.hxToBytes();
}
}
Well, I'm pretty sure it used to work, since we have working code that uses haxe.zip.Reader.unzip
on the nodejs target.
Could it be the case that your zips are not really compressed? Because then it bails out without trying to call new Uncompress()
:
And the default Haxe's implementation of Uncompress
just throws in the constructor:
Anyway I'll try to fix this soon!
Ahhh, your are spot on, that is actually the case my colleague just told me. Thanks a lot.
We will just stay on 4.0.9 for now.
Hey @nadako Any plans on releasing this change? It's easy enough to manually update the Compress class, but it's a bit of a pain with build systems
After updating from 4.0.9 to 6.9.0 the following doesn't compile with Haxe 3.4.7:
haxe.zip.Reader.unzip(null);
It gives the following error:
C:\HaxeToolkit\haxe\std/haxe/zip/Reader.hx:198: characters 10-38 : haxe.zip.Uncompress does not have a constructor