Debian Codegraph @

modules/zip/doc_classes/ZIPPacker.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="ZIPPacker" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
3 <brief_description>
4 Allows the creation of ZIP files.
5 </brief_description>
6 <description>
7 This class implements a writer that allows storing the multiple blobs in a ZIP archive. See also [ZIPReader] and [PCKPacker].
8 [codeblock]
9 # Create a ZIP archive with a single file at its root.
10 func write_zip_file():
11 var writer = ZIPPacker.new()
12 var err = writer.open("user://archive.zip")
13 if err != OK:
14 return err
15 writer.start_file("hello.txt")
16 writer.write_file("Hello World".to_utf8_buffer())
17 writer.close_file()
18
19 writer.close()
20 return OK
21 [/codeblock]
22 </description>
23 <tutorials>
24 </tutorials>
25 <methods>
26 <method name="close">
27 <return type="int" enum="Error" />
28 <description>
29 Closes the underlying resources used by this instance.
30 </description>
31 </method>
32 <method name="close_file">
33 <return type="int" enum="Error" />
34 <description>
35 Stops writing to a file within the archive.
36 It will fail if there is no open file.
37 </description>
38 </method>
39 <method name="open">
40 <return type="int" enum="Error" />
41 <param index="0" name="path" type="String" />
42 <param index="1" name="append" type="int" enum="ZIPPacker.ZipAppend" default="0" />
43 <description>
44 Opens a zip file for writing at the given path using the specified write mode.
45 This must be called before everything else.
46 </description>
47 </method>
48 <method name="start_file">
49 <return type="int" enum="Error" />
50 <param index="0" name="path" type="String" />
51 <description>
52 Starts writing to a file within the archive. Only one file can be written at the same time.
53 Must be called after [method open].
54 </description>
55 </method>
56 <method name="write_file">
57 <return type="int" enum="Error" />
58 <param index="0" name="data" type="PackedByteArray" />
59 <description>
60 Write the given [param data] to the file.
61 Needs to be called after [method start_file].
62 </description>
63 </method>
64 </methods>
65 <members>
66 <member name="compression_level" type="int" setter="set_compression_level" getter="get_compression_level" default="-1">
67 The compression level used when [method start_file] is called. Use [enum ZIPPacker.CompressionLevel] as a reference.
68 </member>
69 </members>
70 <constants>
71 <constant name="APPEND_CREATE" value="0" enum="ZipAppend">
72 Create a new zip archive at the given path.
73 </constant>
74 <constant name="APPEND_CREATEAFTER" value="1" enum="ZipAppend">
75 Append a new zip archive to the end of the already existing file at the given path.
76 </constant>
77 <constant name="APPEND_ADDINZIP" value="2" enum="ZipAppend">
78 Add new files to the existing zip archive at the given path.
79 </constant>
80 <constant name="COMPRESSION_DEFAULT" value="-1" enum="CompressionLevel">
81 Start a file with the default Deflate compression level ([code]6[/code]). This is a good compromise between speed and file size.
82 </constant>
83 <constant name="COMPRESSION_NONE" value="0" enum="CompressionLevel">
84 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).
85 </constant>
86 <constant name="COMPRESSION_FAST" value="1" enum="CompressionLevel">
87 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.
88 </constant>
89 <constant name="COMPRESSION_BEST" value="9" enum="CompressionLevel">
90 Start a file with 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.
91 </constant>
92 </constants>
93 </class>