class_zippacker.rst 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/modules/zip/doc_classes/ZIPPacker.xml.
  6. .. _class_ZIPPacker:
  7. ZIPPacker
  8. =========
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Allows the creation of ZIP files.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. This class implements a writer that allows storing the multiple blobs in a ZIP archive. See also :ref:`ZIPReader<class_ZIPReader>` and :ref:`PCKPacker<class_PCKPacker>`.
  15. ::
  16. # Create a ZIP archive with a single file at its root.
  17. func write_zip_file():
  18. var writer = ZIPPacker.new()
  19. var err = writer.open("user://archive.zip")
  20. if err != OK:
  21. return err
  22. writer.start_file("hello.txt")
  23. writer.write_file("Hello World".to_utf8_buffer())
  24. writer.close_file()
  25. writer.close()
  26. return OK
  27. .. rst-class:: classref-reftable-group
  28. Methods
  29. -------
  30. .. table::
  31. :widths: auto
  32. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`close<class_ZIPPacker_method_close>`\ (\ ) |
  34. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`close_file<class_ZIPPacker_method_close_file>`\ (\ ) |
  36. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`open<class_ZIPPacker_method_open>`\ (\ path\: :ref:`String<class_String>`, append\: :ref:`ZipAppend<enum_ZIPPacker_ZipAppend>` = 0\ ) |
  38. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`start_file<class_ZIPPacker_method_start_file>`\ (\ path\: :ref:`String<class_String>`\ ) |
  40. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`write_file<class_ZIPPacker_method_write_file>`\ (\ data\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  42. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
  43. .. rst-class:: classref-section-separator
  44. ----
  45. .. rst-class:: classref-descriptions-group
  46. Enumerations
  47. ------------
  48. .. _enum_ZIPPacker_ZipAppend:
  49. .. rst-class:: classref-enumeration
  50. enum **ZipAppend**: :ref:`🔗<enum_ZIPPacker_ZipAppend>`
  51. .. _class_ZIPPacker_constant_APPEND_CREATE:
  52. .. rst-class:: classref-enumeration-constant
  53. :ref:`ZipAppend<enum_ZIPPacker_ZipAppend>` **APPEND_CREATE** = ``0``
  54. Create a new zip archive at the given path.
  55. .. _class_ZIPPacker_constant_APPEND_CREATEAFTER:
  56. .. rst-class:: classref-enumeration-constant
  57. :ref:`ZipAppend<enum_ZIPPacker_ZipAppend>` **APPEND_CREATEAFTER** = ``1``
  58. Append a new zip archive to the end of the already existing file at the given path.
  59. .. _class_ZIPPacker_constant_APPEND_ADDINZIP:
  60. .. rst-class:: classref-enumeration-constant
  61. :ref:`ZipAppend<enum_ZIPPacker_ZipAppend>` **APPEND_ADDINZIP** = ``2``
  62. Add new files to the existing zip archive at the given path.
  63. .. rst-class:: classref-section-separator
  64. ----
  65. .. rst-class:: classref-descriptions-group
  66. Method Descriptions
  67. -------------------
  68. .. _class_ZIPPacker_method_close:
  69. .. rst-class:: classref-method
  70. :ref:`Error<enum_@GlobalScope_Error>` **close**\ (\ ) :ref:`🔗<class_ZIPPacker_method_close>`
  71. Closes the underlying resources used by this instance.
  72. .. rst-class:: classref-item-separator
  73. ----
  74. .. _class_ZIPPacker_method_close_file:
  75. .. rst-class:: classref-method
  76. :ref:`Error<enum_@GlobalScope_Error>` **close_file**\ (\ ) :ref:`🔗<class_ZIPPacker_method_close_file>`
  77. Stops writing to a file within the archive.
  78. It will fail if there is no open file.
  79. .. rst-class:: classref-item-separator
  80. ----
  81. .. _class_ZIPPacker_method_open:
  82. .. rst-class:: classref-method
  83. :ref:`Error<enum_@GlobalScope_Error>` **open**\ (\ path\: :ref:`String<class_String>`, append\: :ref:`ZipAppend<enum_ZIPPacker_ZipAppend>` = 0\ ) :ref:`🔗<class_ZIPPacker_method_open>`
  84. Opens a zip file for writing at the given path using the specified write mode.
  85. This must be called before everything else.
  86. .. rst-class:: classref-item-separator
  87. ----
  88. .. _class_ZIPPacker_method_start_file:
  89. .. rst-class:: classref-method
  90. :ref:`Error<enum_@GlobalScope_Error>` **start_file**\ (\ path\: :ref:`String<class_String>`\ ) :ref:`🔗<class_ZIPPacker_method_start_file>`
  91. Starts writing to a file within the archive. Only one file can be written at the same time.
  92. Must be called after :ref:`open<class_ZIPPacker_method_open>`.
  93. .. rst-class:: classref-item-separator
  94. ----
  95. .. _class_ZIPPacker_method_write_file:
  96. .. rst-class:: classref-method
  97. :ref:`Error<enum_@GlobalScope_Error>` **write_file**\ (\ data\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_ZIPPacker_method_write_file>`
  98. Write the given ``data`` to the file.
  99. Needs to be called after :ref:`start_file<class_ZIPPacker_method_start_file>`.
  100. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  101. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  102. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  103. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  104. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  105. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  106. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  107. .. |void| replace:: :abbr:`void (No return value.)`