Skip to content

[ZIPPacker] Add support for Unix permissions and modification time.#115946

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
bruvzg:zip_pack_pt
Feb 6, 2026
Merged

[ZIPPacker] Add support for Unix permissions and modification time.#115946
Repiteo merged 1 commit into
godotengine:masterfrom
bruvzg:zip_pack_pt

Conversation

@bruvzg

@bruvzg bruvzg commented Feb 6, 2026

Copy link
Copy Markdown
Member

No description provided.

@bruvzg bruvzg added this to the 4.x milestone Feb 6, 2026
@bruvzg bruvzg requested review from a team as code owners February 6, 2026 07:49
<method name="add_directory">
<return type="int" enum="Error" />
<param index="0" name="path" type="String" />
<param index="1" name="permissions" type="int" enum="FileAccess.UnixPermissionFlags" is_bitfield="true" default="493" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value seems confusing, how does it match 0755?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Octal 0755 = decimal 493, I do not think we can control how it's showing in the docs.

@bruvzg bruvzg Feb 6, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the enum/bit field values, it might be worth to show it as the list of constants instead of value (or in addition to value).

A quick draft (probably not the best place to add it, will check how to do it proper way next week):

diff
diff --git a/editor/doc/doc_tools.cpp b/editor/doc/doc_tools.cpp
index 5bdd6390ce..e5a5da7fc5 100644
--- a/editor/doc/doc_tools.cpp
+++ b/editor/doc/doc_tools.cpp
@@ -1612,7 +1612,43 @@ static void _write_method_doc(Ref<FileAccess> f, const String &p_name, Vector<Do
                                }

                                if (!a.default_value.is_empty()) {
-                                       _write_string(f, 3, "<param index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape(true) + "\" type=\"" + a.type.xml_escape(true) + "\"" + enum_text + " default=\"" + a.default_value.xml_escape(true) + "\" />");
+                                       String dval = a.default_value.xml_escape(true);
+                                       if (!a.enumeration.is_empty() && a.type.xml_escape(true) == "int") {
+                                               if (a.is_bitfield) {
+                                                       int64_t cval = dval.to_int();
+                                                       String cname = a.enumeration.xml_escape(true).get_slice(".", 0);
+                                                       String ename = a.enumeration.xml_escape(true).get_slice(".", 1);
+                                                       List<StringName> consts;
+                                                       ClassDB::get_enum_constants(cname, ename, &consts);
+                                                       dval = String();
+                                                       for (const StringName &c : consts) {
+                                                               int64_t val = ClassDB::get_integer_constant(cname, c);
+                                                               if ((cval & val) == val) {
+                                                                       if (!dval.is_empty()) {
+                                                                               dval += " | ";
+                                                                       }
+                                                                       dval += c;
+                                                                       cval &= ~val;
+                                                               }
+                                                       }
+                                                       if (cval != 0) {
+                                                               dval += " | " + itos(cval);
+                                                       }
+                                               } else {
+                                                       int64_t cval = dval.to_int();
+                                                       String cname = a.enumeration.xml_escape(true).get_slice(".", 0);
+                                                       String ename = a.enumeration.xml_escape(true).get_slice(".", 1);
+                                                       List<StringName> consts;
+                                                       ClassDB::get_enum_constants(cname, ename, &consts);
+                                                       for (const StringName &c : consts) {
+                                                               if (cval == ClassDB::get_integer_constant(cname, c)) {
+                                                                       dval = c;
+                                                                       break;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                                       _write_string(f, 3, "<param index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape(true) + "\" type=\"" + a.type.xml_escape(true) + "\"" + enum_text + " default=\"" + dval + "\" />");
                                } else {
                                        _write_string(f, 3, "<param index=\"" + itos(j) + "\" name=\"" + a.name.xml_escape(true) + "\" type=\"" + a.type.xml_escape(true) + "\"" + enum_text + " />");
                                }

Produce following docs, which looks more readable:

		<method name="open">
			<return type="int" enum="Error" />
			<param index="0" name="path" type="String" />
			<param index="1" name="append" type="int" enum="ZIPPacker.ZipAppend" default="APPEND_CREATE" />
			<description>
				Opens a zip file for writing at the given path using the specified write mode.
				This must be called before everything else.
			</description>
		</method>
		<method name="start_file">
			<return type="int" enum="Error" />
			<param index="0" name="path" type="String" />
			<param index="1" name="permissions" type="int" enum="FileAccess.UnixPermissionFlags" is_bitfield="true" default="UNIX_READ_OWNER | UNIX_WRITE_OWNER | UNIX_READ_GROUP | UNIX_READ_OTHER" />
			<param index="2" name="modified_time" type="int" default="0" />
			<description>
				Starts writing to a file within the archive. Only one file can be written at the same time. If [param modified_time] is set to [code]0[/code], current system time is used.
				Must be called after [method open].
			</description>
		</method>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the record, I just saw this PR which seems adjacent (for inspector, not docs).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akien-mga akien-mga modified the milestones: 4.x, 4.7 Feb 6, 2026
Comment thread modules/zip/zip_packer.cpp Outdated
@Repiteo Repiteo merged commit a1604ab into godotengine:master Feb 6, 2026
20 checks passed
@Repiteo

Repiteo commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Thanks!

rivie13 pushed a commit to rivie13/Phoenix-Agentic-Engine that referenced this pull request Feb 16, 2026
[ZIPPacker] Add support for Unix permissions and modification time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants