Add initial support for LZMA decompression on HTML5 target

This commit is contained in:
Joshua Granick
2024-05-31 08:09:16 -07:00
parent c0ca857fa6
commit d0678156dd
4 changed files with 27 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package lime._internal.format;
import haxe.io.Bytes;
import lime._internal.backend.native.NativeCFFI;
import lime.utils.UInt8Array;
#if flash
import flash.utils.CompressionAlgorithm;
import flash.utils.ByteArray;
@@ -24,6 +25,16 @@ class LZMA
if (data == null) return null;
return @:privateAccess new Bytes(data.length, data.b);
#end
#elseif js
var data = untyped #if haxe4 js.Syntax.code #else __js__ #end ("LZMA.compress")(new UInt8Array(bytes.getData()), 5);
if (data is String)
{
return Bytes.ofString(data);
}
else
{
return Bytes.ofData(cast data);
}
#elseif flash
var byteArray:ByteArray = cast bytes.getData();
@@ -47,6 +58,16 @@ class LZMA
if (data == null) return null;
return @:privateAccess new Bytes(data.length, data.b);
#end
#elseif js
var data = untyped #if haxe4 js.Syntax.code #else __js__ #end ("LZMA.decompress")(new UInt8Array(bytes.getData()));
if (data is String)
{
return Bytes.ofString(data);
}
else
{
return Bytes.ofData(cast data);
}
#elseif flash
var byteArray:ByteArray = cast bytes.getData();