Skip to content
0.2.0-dev Download ZIP
72 lines ·3.9 KB Raw
1<?xml version="1.0" encoding="UTF-8" ?>
2<class name="PCKPacker" inherits="RefCounted" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 Creates packages that can be loaded into a running project.
5 </brief_description>
6 <description>
7 The [PCKPacker] is used to create packages that can be loaded into a running project using [method ProjectSettings.load_resource_pack].
8 [codeblocks]
9 [gdscript]
10 var packer = PCKPacker.new()
11 packer.pck_start("test.pck")
12 packer.add_file("res://text.txt", "text.txt")
13 packer.flush()
14 [/gdscript]
15 [csharp]
16 var packer = new PckPacker();
17 packer.PckStart("test.pck");
18 packer.AddFile("res://text.txt", "text.txt");
19 packer.Flush();
20 [/csharp]
21 [/codeblocks]
22 The above [PCKPacker] creates package [code]test.pck[/code], then adds a file named [code]text.txt[/code] at the root of the package.
23 [b]Note:[/b] PCK is Godot's own pack file format. To create ZIP archives that can be read by any program, use [ZIPPacker] instead.
24 </description>
25 <tutorials>
26 </tutorials>
27 <methods>
28 <method name="add_file">
29 <return type="int" enum="Error" />
30 <param index="0" name="target_path" type="String" />
31 <param index="1" name="source_path" type="String" />
32 <param index="2" name="encrypt" type="bool" default="false" />
33 <description>
34 Adds the [param source_path] file to the current PCK package at the [param target_path] internal path. The [code]res://[/code] prefix for [param target_path] is optional and stripped internally. File content is immediately written to the PCK.
35 </description>
36 </method>
37 <method name="add_file_from_buffer">
38 <return type="int" enum="Error" />
39 <param index="0" name="target_path" type="String" />
40 <param index="1" name="data" type="PackedByteArray" />
41 <param index="2" name="encrypt" type="bool" default="false" />
42 <description>
43 Adds the [param data] to the current PCK package at the [param target_path] internal path. The [code]res://[/code] prefix for [param target_path] is optional and stripped internally. File content is immediately written to the PCK.
44 </description>
45 </method>
46 <method name="add_file_removal">
47 <return type="int" enum="Error" />
48 <param index="0" name="target_path" type="String" />
49 <description>
50 Registers a file removal of the [param target_path] internal path to the PCK. This is mainly used for patches. If the file at this path has been loaded from a previous PCK, it will be removed. The [code]res://[/code] prefix for [param target_path] is optional and stripped internally.
51 </description>
52 </method>
53 <method name="flush">
54 <return type="int" enum="Error" />
55 <param index="0" name="verbose" type="bool" default="false" />
56 <description>
57 Writes the file directory and closes the PCK. If [param verbose] is [code]true[/code], a list of files added will be printed to the console for easier debugging.
58 [b]Note:[/b] [PCKPacker] will automatically flush when it's freed, which happens when it goes out of scope or when it gets assigned with [code]null[/code]. In C# the reference must be disposed after use, either with the [code]using[/code] statement or by calling the [code]Dispose[/code] method directly.
59 </description>
60 </method>
61 <method name="pck_start">
62 <return type="int" enum="Error" />
63 <param index="0" name="pck_path" type="String" />
64 <param index="1" name="alignment" type="int" default="32" />
65 <param index="2" name="key" type="String" default="&quot;0000000000000000000000000000000000000000000000000000000000000000&quot;" />
66 <param index="3" name="encrypt_directory" type="bool" default="false" />
67 <description>
68 Creates a new PCK file at the file path [param pck_path]. The [code].pck[/code] file extension isn't added automatically, so it should be part of [param pck_path] (even though it's not required).
69 </description>
70 </method>
71 </methods>
72</class>