Files
godot-docs/classes/class_zippacker.rst
2022-11-07 14:06:01 +01:00

125 lines
5.1 KiB
ReStructuredText

:github_url: hide
.. DO NOT EDIT THIS FILE!!!
.. Generated automatically from Godot engine sources.
.. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
.. XML source: https://github.com/godotengine/godot/tree/master/modules/zip/doc_classes/ZIPPacker.xml.
.. _class_ZIPPacker:
ZIPPacker
=========
**Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
Allows the creation of zip files.
Description
-----------
This class implements a writer that allows storing the multiple blobs in a zip archive.
::
func write_zip_file():
var writer := ZIPPacker.new()
var err := writer.open("user://archive.zip")
if err != OK:
return err
writer.start_file("hello.txt")
writer.write_file("Hello World".to_utf8_buffer())
writer.close_file()
writer.close()
return OK
Methods
-------
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`close<class_ZIPPacker_method_close>` **(** **)** |
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`close_file<class_ZIPPacker_method_close_file>` **(** **)** |
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`open<class_ZIPPacker_method_open>` **(** :ref:`String<class_String>` path, :ref:`ZipAppend<enum_ZIPPacker_ZipAppend>` append=0 **)** |
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`start_file<class_ZIPPacker_method_start_file>` **(** :ref:`String<class_String>` path **)** |
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`write_file<class_ZIPPacker_method_write_file>` **(** :ref:`PackedByteArray<class_PackedByteArray>` data **)** |
+---------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
Enumerations
------------
.. _enum_ZIPPacker_ZipAppend:
.. _class_ZIPPacker_constant_APPEND_CREATE:
.. _class_ZIPPacker_constant_APPEND_CREATEAFTER:
.. _class_ZIPPacker_constant_APPEND_ADDINZIP:
enum **ZipAppend**:
- **APPEND_CREATE** = **0**
- **APPEND_CREATEAFTER** = **1**
- **APPEND_ADDINZIP** = **2**
Method Descriptions
-------------------
.. _class_ZIPPacker_method_close:
- :ref:`Error<enum_@GlobalScope_Error>` **close** **(** **)**
Closes the underlying resources used by this instance.
----
.. _class_ZIPPacker_method_close_file:
- :ref:`Error<enum_@GlobalScope_Error>` **close_file** **(** **)**
Stops writing to a file within the archive.
It will fail if there is no open file.
----
.. _class_ZIPPacker_method_open:
- :ref:`Error<enum_@GlobalScope_Error>` **open** **(** :ref:`String<class_String>` path, :ref:`ZipAppend<enum_ZIPPacker_ZipAppend>` append=0 **)**
Opens a zip file for writing at the given path using the specified write mode.
This must be called before everything else.
----
.. _class_ZIPPacker_method_start_file:
- :ref:`Error<enum_@GlobalScope_Error>` **start_file** **(** :ref:`String<class_String>` path **)**
Starts writing to a file within the archive. Only one file can be written at the same time.
Must be called after :ref:`open<class_ZIPPacker_method_open>`.
----
.. _class_ZIPPacker_method_write_file:
- :ref:`Error<enum_@GlobalScope_Error>` **write_file** **(** :ref:`PackedByteArray<class_PackedByteArray>` data **)**
Write the given ``data`` to the file.
Needs to be called after :ref:`start_file<class_ZIPPacker_method_start_file>`.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
.. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
.. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`