Przeglądaj źródła

added haxe.zip.Compres/Uncompress/Flush

Nicolas Cannasse 12 lat temu
rodzic
commit
69b3c7df6c

+ 2 - 1
std/cpp/zip/Compress.hx → std/cpp/_std/zip/Compress.hx

@@ -19,8 +19,9 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  */
-package cpp.zip;
+package haxe.zip;
  
+@:coreApi
 class Compress {
  
 	var s : Dynamic;

+ 2 - 1
std/cpp/zip/Uncompress.hx → std/cpp/_std/zip/Uncompress.hx

@@ -19,8 +19,9 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  */
-package cpp.zip;
+package haxe.zip;
 
+@:coreApi
 class Uncompress {
 	var s : Dynamic;
 

+ 1 - 7
std/cpp/zip/Flush.hx

@@ -21,10 +21,4 @@
  */
 package cpp.zip;
 
-enum Flush {
-	NO;
-	SYNC;
-	FULL;
-	FINISH;
-	BLOCK;
-}
+typedef Flush = haxe.zip.Flush;

+ 45 - 0
std/haxe/zip/Compress.hx

@@ -0,0 +1,45 @@
+/*
+ * Copyright (C)2005-2012 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe.zip;
+
+class Compress {
+
+	public function new( level : Int ) {
+		throw "Not implemented for this platform";
+	}
+
+	public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } {
+		return null;
+	}
+
+	public function setFlushMode( f : Flush ) {
+	}
+
+	public function close() {
+	}
+
+	public static function run( s : haxe.io.Bytes, level : Int ) : haxe.io.Bytes {
+		throw "Not implemented for this platform";
+		return null;
+	}
+
+}

+ 30 - 0
std/haxe/zip/Flush.hx

@@ -0,0 +1,30 @@
+/*
+ * Copyright (C)2005-2012 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe.zip;
+
+enum Flush {
+	NO;
+	SYNC;
+	FULL;
+	FINISH;
+	BLOCK;
+}

+ 1 - 5
std/haxe/zip/Tools.hx

@@ -26,17 +26,13 @@ class Tools {
 	public static function compress( f : Entry, level : Int ) {
 		if( f.compressed )
 			return;
-		#if neko
 		// this should be optimized with a temp buffer
 		// that would discard the first two bytes
 		// (in order to prevent 2x mem usage for large files)
-		var data = neko.zip.Compress.run( f.data, level );
+		var data = haxe.zip.Compress.run( f.data, level );
 		f.compressed = true;
 		f.data = data.sub(2,data.length-6);
 		f.dataSize = f.data.length;
-		#else
-		throw "No compress support";
-		#end
 	}
 
 }

+ 44 - 0
std/haxe/zip/Uncompress.hx

@@ -0,0 +1,44 @@
+/*
+ * Copyright (C)2005-2012 Haxe Foundation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+package haxe.zip;
+
+class Uncompress {
+
+	public function new( windowBits : Int ) {
+		throw "Not implemented for this platform";
+	}
+
+	public function execute( src : haxe.io.Bytes, srcPos : Int, dst : haxe.io.Bytes, dstPos : Int ) : { done : Bool, read : Int, write : Int } {
+		return null;
+	}
+
+	public function setFlushMode( f : Flush ) {
+	}
+
+	public function close() {
+	}
+
+	public static function run( src : haxe.io.Bytes, ?bufsize ) : haxe.io.Bytes {
+		return InflateImpl.run(src,bufsize);
+	}
+
+}

+ 2 - 1
std/neko/zip/Compress.hx → std/neko/_std/zip/Compress.hx

@@ -19,8 +19,9 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  */
-package neko.zip;
+package haxe.zip;
 
+@:coreApi
 class Compress {
 
 	var s : Dynamic;

+ 2 - 1
std/neko/zip/Uncompress.hx → std/neko/_std/zip/Uncompress.hx

@@ -19,8 +19,9 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  */
-package neko.zip;
+package haxe.zip;
 
+@:coreApi
 class Uncompress {
 
 	var s : Dynamic;

+ 1 - 7
std/neko/zip/Flush.hx

@@ -21,10 +21,4 @@
  */
 package neko.zip;
 
-enum Flush {
-	NO;
-	SYNC;
-	FULL;
-	FINISH;
-	BLOCK;
-}
+typedef Flush = haxe.zip.Flush;