Merge pull request #97286 from Rynzier/master
Clarify PCK path argument in `PCKPacker.pck_start`
This commit is contained in:
commit
9c9e704a2b
|
@ -47,12 +47,12 @@ static int _get_pad(int p_alignment, int p_n) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCKPacker::_bind_methods() {
|
void PCKPacker::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("pck_start", "pck_name", "alignment", "key", "encrypt_directory"), &PCKPacker::pck_start, DEFVAL(32), DEFVAL("0000000000000000000000000000000000000000000000000000000000000000"), DEFVAL(false));
|
ClassDB::bind_method(D_METHOD("pck_start", "pck_path", "alignment", "key", "encrypt_directory"), &PCKPacker::pck_start, DEFVAL(32), DEFVAL("0000000000000000000000000000000000000000000000000000000000000000"), DEFVAL(false));
|
||||||
ClassDB::bind_method(D_METHOD("add_file", "pck_path", "source_path", "encrypt"), &PCKPacker::add_file, DEFVAL(false));
|
ClassDB::bind_method(D_METHOD("add_file", "pck_path", "source_path", "encrypt"), &PCKPacker::add_file, DEFVAL(false));
|
||||||
ClassDB::bind_method(D_METHOD("flush", "verbose"), &PCKPacker::flush, DEFVAL(false));
|
ClassDB::bind_method(D_METHOD("flush", "verbose"), &PCKPacker::flush, DEFVAL(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
Error PCKPacker::pck_start(const String &p_file, int p_alignment, const String &p_key, bool p_encrypt_directory) {
|
Error PCKPacker::pck_start(const String &p_pck_path, int p_alignment, const String &p_key, bool p_encrypt_directory) {
|
||||||
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).");
|
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).");
|
||||||
ERR_FAIL_COND_V_MSG(p_alignment <= 0, ERR_CANT_CREATE, "Invalid alignment, must be greater then 0.");
|
ERR_FAIL_COND_V_MSG(p_alignment <= 0, ERR_CANT_CREATE, "Invalid alignment, must be greater then 0.");
|
||||||
|
|
||||||
|
@ -83,8 +83,8 @@ Error PCKPacker::pck_start(const String &p_file, int p_alignment, const String &
|
||||||
}
|
}
|
||||||
enc_dir = p_encrypt_directory;
|
enc_dir = p_encrypt_directory;
|
||||||
|
|
||||||
file = FileAccess::open(p_file, FileAccess::WRITE);
|
file = FileAccess::open(p_pck_path, FileAccess::WRITE);
|
||||||
ERR_FAIL_COND_V_MSG(file.is_null(), ERR_CANT_CREATE, "Can't open file to write: " + String(p_file) + ".");
|
ERR_FAIL_COND_V_MSG(file.is_null(), ERR_CANT_CREATE, "Can't open file to write: " + String(p_pck_path) + ".");
|
||||||
|
|
||||||
alignment = p_alignment;
|
alignment = p_alignment;
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ Error PCKPacker::pck_start(const String &p_file, int p_alignment, const String &
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
Error PCKPacker::add_file(const String &p_file, const String &p_src, bool p_encrypt) {
|
Error PCKPacker::add_file(const String &p_pck_path, const String &p_src, bool p_encrypt) {
|
||||||
ERR_FAIL_COND_V_MSG(file.is_null(), ERR_INVALID_PARAMETER, "File must be opened before use.");
|
ERR_FAIL_COND_V_MSG(file.is_null(), ERR_INVALID_PARAMETER, "File must be opened before use.");
|
||||||
|
|
||||||
Ref<FileAccess> f = FileAccess::open(p_src, FileAccess::READ);
|
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
|
||||||
File pf;
|
File pf;
|
||||||
// Simplify path here and on every 'files' access so that paths that have extra '/'
|
// Simplify path here and on every 'files' access so that paths that have extra '/'
|
||||||
// symbols in them still match to the MD5 hash for the saved path.
|
// symbols in them still match to the MD5 hash for the saved path.
|
||||||
pf.path = p_file.simplify_path();
|
pf.path = p_pck_path.simplify_path();
|
||||||
pf.src_path = p_src;
|
pf.src_path = p_src;
|
||||||
pf.ofs = ofs;
|
pf.ofs = ofs;
|
||||||
pf.size = f->get_length();
|
pf.size = f->get_length();
|
||||||
|
|
|
@ -58,8 +58,8 @@ class PCKPacker : public RefCounted {
|
||||||
Vector<File> files;
|
Vector<File> files;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Error pck_start(const String &p_file, int p_alignment = 32, const String &p_key = "0000000000000000000000000000000000000000000000000000000000000000", bool p_encrypt_directory = false);
|
Error pck_start(const String &p_pck_path, int p_alignment = 32, const String &p_key = "0000000000000000000000000000000000000000000000000000000000000000", bool p_encrypt_directory = false);
|
||||||
Error add_file(const String &p_file, const String &p_src, bool p_encrypt = false);
|
Error add_file(const String &p_pck_path, const String &p_src, bool p_encrypt = false);
|
||||||
Error flush(bool p_verbose = false);
|
Error flush(bool p_verbose = false);
|
||||||
|
|
||||||
PCKPacker() {}
|
PCKPacker() {}
|
||||||
|
|
|
@ -42,12 +42,12 @@
|
||||||
</method>
|
</method>
|
||||||
<method name="pck_start">
|
<method name="pck_start">
|
||||||
<return type="int" enum="Error" />
|
<return type="int" enum="Error" />
|
||||||
<param index="0" name="pck_name" type="String" />
|
<param index="0" name="pck_path" type="String" />
|
||||||
<param index="1" name="alignment" type="int" default="32" />
|
<param index="1" name="alignment" type="int" default="32" />
|
||||||
<param index="2" name="key" type="String" default=""0000000000000000000000000000000000000000000000000000000000000000"" />
|
<param index="2" name="key" type="String" default=""0000000000000000000000000000000000000000000000000000000000000000"" />
|
||||||
<param index="3" name="encrypt_directory" type="bool" default="false" />
|
<param index="3" name="encrypt_directory" type="bool" default="false" />
|
||||||
<description>
|
<description>
|
||||||
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).
|
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).
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
</methods>
|
</methods>
|
||||||
|
|
Loading…
Reference in New Issue