class_zipreader.rst 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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/4.1/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.1/modules/zip/doc_classes/ZIPReader.xml.
  6. .. _class_ZIPReader:
  7. ZIPReader
  8. =========
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. Allows reading the content of a zip file.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. This class implements a reader that can extract the content of individual files inside a zip archive.
  15. ::
  16. func read_zip_file():
  17. var reader := ZIPReader.new()
  18. var err := reader.open("user://archive.zip")
  19. if err != OK:
  20. return PackedByteArray()
  21. var res := reader.read_file("hello.txt")
  22. reader.close()
  23. return res
  24. .. rst-class:: classref-reftable-group
  25. Methods
  26. -------
  27. .. table::
  28. :widths: auto
  29. +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`close<class_ZIPReader_method_close>` **(** **)** |
  31. +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_files<class_ZIPReader_method_get_files>` **(** **)** |
  33. +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`open<class_ZIPReader_method_open>` **(** :ref:`String<class_String>` path **)** |
  35. +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`read_file<class_ZIPReader_method_read_file>` **(** :ref:`String<class_String>` path, :ref:`bool<class_bool>` case_sensitive=true **)** |
  37. +---------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------+
  38. .. rst-class:: classref-section-separator
  39. ----
  40. .. rst-class:: classref-descriptions-group
  41. Method Descriptions
  42. -------------------
  43. .. _class_ZIPReader_method_close:
  44. .. rst-class:: classref-method
  45. :ref:`Error<enum_@GlobalScope_Error>` **close** **(** **)**
  46. Closes the underlying resources used by this instance.
  47. .. rst-class:: classref-item-separator
  48. ----
  49. .. _class_ZIPReader_method_get_files:
  50. .. rst-class:: classref-method
  51. :ref:`PackedStringArray<class_PackedStringArray>` **get_files** **(** **)**
  52. Returns the list of names of all files in the loaded archive.
  53. Must be called after :ref:`open<class_ZIPReader_method_open>`.
  54. .. rst-class:: classref-item-separator
  55. ----
  56. .. _class_ZIPReader_method_open:
  57. .. rst-class:: classref-method
  58. :ref:`Error<enum_@GlobalScope_Error>` **open** **(** :ref:`String<class_String>` path **)**
  59. Opens the zip archive at the given ``path`` and reads its file index.
  60. .. rst-class:: classref-item-separator
  61. ----
  62. .. _class_ZIPReader_method_read_file:
  63. .. rst-class:: classref-method
  64. :ref:`PackedByteArray<class_PackedByteArray>` **read_file** **(** :ref:`String<class_String>` path, :ref:`bool<class_bool>` case_sensitive=true **)**
  65. Loads the whole content of a file in the loaded zip archive into memory and returns it.
  66. Must be called after :ref:`open<class_ZIPReader_method_open>`.
  67. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  68. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  69. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  70. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  71. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  72. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  73. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`