Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

haxe.zip.Reader doesn't work for hxnodejs 6.9.0 + Haxe 3.4.7 #118

Open
mikkelmr opened this issue Mar 13, 2019 · 5 comments
Open

haxe.zip.Reader doesn't work for hxnodejs 6.9.0 + Haxe 3.4.7 #118

mikkelmr opened this issue Mar 13, 2019 · 5 comments

Comments

@mikkelmr
Copy link

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

@nadako
Copy link
Member

nadako commented Mar 13, 2019

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();
	}

}

@mikkelmr
Copy link
Author

Well, I'm pretty sure it used to work, since we have working code that uses haxe.zip.Reader.unzip on the nodejs target.

@nadako
Copy link
Member

nadako commented Mar 14, 2019

Could it be the case that your zips are not really compressed? Because then it bails out without trying to call new Uncompress():

https://github.com/HaxeFoundation/haxe/blob/39cdd730c4a1dfa629178a631be8e6baaec1441c/std/haxe/zip/Reader.hx#L198

And the default Haxe's implementation of Uncompress just throws in the constructor:

https://github.com/HaxeFoundation/haxe/blob/39cdd730c4a1dfa629178a631be8e6baaec1441c/std/haxe/zip/Uncompress.hx#L27.

Anyway I'll try to fix this soon!

@mikkelmr
Copy link
Author

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.

@peteshand
Copy link
Contributor

peteshand commented Sep 25, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants