Add compression level support to ZipPacker

This commit is contained in:
mmurphy316
2025-02-25 09:30:46 -05:00
parent 30bb49ec1f
commit 0ed8bf89ae
11 changed files with 229 additions and 2 deletions

View File

@ -62,6 +62,11 @@
</description>
</method>
</methods>
<members>
<member name="compression_level" type="int" setter="set_compression_level" getter="get_compression_level" default="-1">
The compression level used when [method start_file] is called. Use [enum ZIPPacker.CompressionLevel] as a reference.
</member>
</members>
<constants>
<constant name="APPEND_CREATE" value="0" enum="ZipAppend">
Create a new zip archive at the given path.
@ -72,5 +77,17 @@
<constant name="APPEND_ADDINZIP" value="2" enum="ZipAppend">
Add new files to the existing zip archive at the given path.
</constant>
<constant name="COMPRESSION_DEFAULT" value="-1" enum="CompressionLevel">
Start a file with the default Deflate compression level ([code]6[/code]). This is a good compromise between speed and file size.
</constant>
<constant name="COMPRESSION_NONE" value="0" enum="CompressionLevel">
Start a file with no compression. This is also known as the "Store" compression mode and is the fastest method of packing files inside a ZIP archive. Consider using this mode for files that are already compressed (such as JPEG, PNG, MP3, or Ogg Vorbis files).
</constant>
<constant name="COMPRESSION_FAST" value="1" enum="CompressionLevel">
Start a file with the fastest Deflate compression level ([code]1[/code]). This is fast to compress, but results in larger file sizes than [constant COMPRESSION_DEFAULT]. Decompression speed is generally unaffected by the chosen compression level.
</constant>
<constant name="COMPRESSION_BEST" value="9" enum="CompressionLevel">
Start a file with the the best Deflate compression level ([code]9[/code]). This is slow to compress, but results in smaller file sizes than [constant COMPRESSION_DEFAULT]. Decompression speed is generally unaffected by the chosen compression level.
</constant>
</constants>
</class>

View File

@ -61,6 +61,14 @@
Must be called after [method open].
</description>
</method>
<method name="get_compression_level">
<return type="int" />
<param index="0" name="path" type="String" />
<param index="1" name="case_sensitive" type="bool" default="true" />
<description>
Returns the compression level of the file in the loaded zip archive. Returns [code]-1[/code] if the file doesn't exist or any other error occurs. Must be called after [method open].
</description>
</method>
<method name="get_files">
<return type="PackedStringArray" />
<description>