I would like to know what exactly, does it mean by :
protected static var HAS_UNCOMPRESS:Boolean = (describeType(ByteArray).factory.method.(@name == "uncompress").parameter.length() > 0);
protected static var HAS_INFLATE:Boolean = (describeType(ByteArray).factory.method.(@name == "inflate").length() > 0);
describeType() returns an XML object that describes the available properties and methods on a type.
The code appears to be checking whether the ByteArray class has uncompress() and inflate() methods. These methods may not have existed in older versions of Flash/AIR.
joshtynjala so in 2023, is it necessary?
Not necessary — unless you plan to use extremely old versions of AIR, for some reason.
joshtynjala so just confirming, both variables should be true? Am I right?
joshtynjala after looking at the code some how I have the feeling that both should not be true.
It should be HAS_INFLATE true & HAS_UNCOMRESSED false.
Both should be true because the ByteArray class has both functions in the latest versions of AIR from Harman.
joshtynjala yes, but in Zipfile.as, they are checking for HAS_INFLATE first, which means HAS_UNCOMPRESSED is only required for older sdks, where there is no inflate function.
Also the functions compressed & uncompressed have some changes in the later versions.
Shaun_Max uncompress has one parameter, then hasUncompress = true in the above code (describeType(ByteArray).factory.method.(@name == "uncompress").parameter.length() > 0), assuming the developer is using latest Adobe AIR version. ByteArray#uncompress(). I think setting both as true doesn't matter, I guess?
hasUncompress = true
describeType(ByteArray).factory.method.(@name == "uncompress").parameter.length() > 0
Shaun_Max which means HAS_UNCOMPRESSED is only required for older sdks, where there is no inflate function.
Yes, but that doesn't mean that it needs to be false. I see no reason why both values can't be true.
However, you make a good point about how it is only required for older SDKs. If that's true, why not just remove it completely?
joshtynjala yes, that can also be done 👍
I was checking this file as a part of Haxe conversion ? Is that necessary? I believe haxe/OpenFL should be already having a similar zip file ?
They don't seem to have documentation, but yes, it looks like Haxe has classes for reading and writing ZIP files in the standard library:
OpenFL also appears to have implementations for inflate() on most platforms it supports.