Skip to content

Commit 7b7164c

Browse files
Rynzierakien-mga
andcommitted
Clarify PCK path argument in PCKPacker.pck_start
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
1 parent e4e024a commit 7b7164c

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

core/io/pck_packer.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ static int _get_pad(int p_alignment, int p_n) {
4747
}
4848

4949
void PCKPacker::_bind_methods() {
50-
ClassDB::bind_method(D_METHOD("pck_start", "pck_name", "alignment", "key", "encrypt_directory"), &PCKPacker::pck_start, DEFVAL(32), DEFVAL("0000000000000000000000000000000000000000000000000000000000000000"), DEFVAL(false));
50+
ClassDB::bind_method(D_METHOD("pck_start", "pck_path", "alignment", "key", "encrypt_directory"), &PCKPacker::pck_start, DEFVAL(32), DEFVAL("0000000000000000000000000000000000000000000000000000000000000000"), DEFVAL(false));
5151
ClassDB::bind_method(D_METHOD("add_file", "pck_path", "source_path", "encrypt"), &PCKPacker::add_file, DEFVAL(false));
5252
ClassDB::bind_method(D_METHOD("flush", "verbose"), &PCKPacker::flush, DEFVAL(false));
5353
}
5454

55-
Error PCKPacker::pck_start(const String &p_file, int p_alignment, const String &p_key, bool p_encrypt_directory) {
55+
Error PCKPacker::pck_start(const String &p_pck_path, int p_alignment, const String &p_key, bool p_encrypt_directory) {
5656
ERR_FAIL_COND_V_MSG((p_key.is_empty() || !p_key.is_valid_hex_number(false) || p_key.length() != 64), ERR_CANT_CREATE, "Invalid Encryption Key (must be 64 characters long).");
5757
ERR_FAIL_COND_V_MSG(p_alignment <= 0, ERR_CANT_CREATE, "Invalid alignment, must be greater then 0.");
5858

@@ -83,8 +83,8 @@ Error PCKPacker::pck_start(const String &p_file, int p_alignment, const String &
8383
}
8484
enc_dir = p_encrypt_directory;
8585

86-
file = FileAccess::open(p_file, FileAccess::WRITE);
87-
ERR_FAIL_COND_V_MSG(file.is_null(), ERR_CANT_CREATE, "Can't open file to write: " + String(p_file) + ".");
86+
file = FileAccess::open(p_pck_path, FileAccess::WRITE);
87+
ERR_FAIL_COND_V_MSG(file.is_null(), ERR_CANT_CREATE, "Can't open file to write: " + String(p_pck_path) + ".");
8888

8989
alignment = p_alignment;
9090

@@ -106,7 +106,7 @@ Error PCKPacker::pck_start(const String &p_file, int p_alignment, const String &
106106
return OK;
107107
}
108108

109-
Error PCKPacker::add_file(const String &p_file, const String &p_src, bool p_encrypt) {
109+
Error PCKPacker::add_file(const String &p_pck_path, const String &p_src, bool p_encrypt) {
110110
ERR_FAIL_COND_V_MSG(file.is_null(), ERR_INVALID_PARAMETER, "File must be opened before use.");
111111

112112
Ref<FileAccess> f = FileAccess::open(p_src, FileAccess::READ);
@@ -117,7 +117,7 @@ Error PCKPacker::add_file(const String &p_file, const String &p_src, bool p_encr
117117
File pf;
118118
// Simplify path here and on every 'files' access so that paths that have extra '/'
119119
// symbols in them still match to the MD5 hash for the saved path.
120-
pf.path = p_file.simplify_path();
120+
pf.path = p_pck_path.simplify_path();
121121
pf.src_path = p_src;
122122
pf.ofs = ofs;
123123
pf.size = f->get_length();

core/io/pck_packer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ class PCKPacker : public RefCounted {
5858
Vector<File> files;
5959

6060
public:
61-
Error pck_start(const String &p_file, int p_alignment = 32, const String &p_key = "0000000000000000000000000000000000000000000000000000000000000000", bool p_encrypt_directory = false);
62-
Error add_file(const String &p_file, const String &p_src, bool p_encrypt = false);
61+
Error pck_start(const String &p_pck_path, int p_alignment = 32, const String &p_key = "0000000000000000000000000000000000000000000000000000000000000000", bool p_encrypt_directory = false);
62+
Error add_file(const String &p_pck_path, const String &p_src, bool p_encrypt = false);
6363
Error flush(bool p_verbose = false);
6464

6565
PCKPacker() {}

doc/classes/PCKPacker.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@
4242
</method>
4343
<method name="pck_start">
4444
<return type="int" enum="Error" />
45-
<param index="0" name="pck_name" type="String" />
45+
<param index="0" name="pck_path" type="String" />
4646
<param index="1" name="alignment" type="int" default="32" />
4747
<param index="2" name="key" type="String" default="&quot;0000000000000000000000000000000000000000000000000000000000000000&quot;" />
4848
<param index="3" name="encrypt_directory" type="bool" default="false" />
4949
<description>
50-
Creates a new PCK file with the name [param pck_name]. The [code].pck[/code] file extension isn't added automatically, so it should be part of [param pck_name] (even though it's not required).
50+
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).
5151
</description>
5252
</method>
5353
</methods>

0 commit comments

Comments
 (0)