Browse Source

[java] add nadako-deflate

closes #2861
Simon Krajewski 6 years ago
parent
commit
43f00c851a
1 changed files with 13 additions and 2 deletions
  1. 13 2
      std/java/_std/haxe/zip/Uncompress.hx

+ 13 - 2
std/java/_std/haxe/zip/Uncompress.hx

@@ -21,20 +21,31 @@
  */
  */
 package haxe.zip;
 package haxe.zip;
 
 
+import java.util.zip.Inflater;
+
 class Uncompress
 class Uncompress
 {
 {
+	final inflater:Inflater;
+
 	public function new( ?windowBits : Int ) {
 	public function new( ?windowBits : Int ) {
-		throw "Not implemented for this platform";
+		inflater = new Inflater(windowBits != null && windowBits < 0);
 	}
 	}
 
 
 	public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } {
 	public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } {
-		return null;
+		inflater.setInput(src.getData(), srcPos, src.length - srcPos);
+		inflater.inflate(dst.getData(), dstPos, dst.length - dstPos);
+		return {
+			done: inflater.finished(),
+			read: Int64.toInt(inflater.getBytesRead()),
+			write: Int64.toInt(inflater.getBytesWritten())
+		};
 	}
 	}
 
 
 	public function setFlushMode( f : FlushMode ) {
 	public function setFlushMode( f : FlushMode ) {
 	}
 	}
 
 
 	public function close() {
 	public function close() {
+		inflater.end();
 	}
 	}
 
 
 	public static function run( src : haxe.io.Bytes, ?bufsize : Int ) : haxe.io.Bytes
 	public static function run( src : haxe.io.Bytes, ?bufsize : Int ) : haxe.io.Bytes