ZIPReader.xml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="ZIPReader" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
  3. <brief_description>
  4. Allows reading the content of a zip file.
  5. </brief_description>
  6. <description>
  7. This class implements a reader that can extract the content of individual files inside a zip archive.
  8. [codeblock]
  9. func read_zip_file():
  10. var reader := ZIPReader.new()
  11. var err := reader.open("user://archive.zip")
  12. if err != OK:
  13. return PackedByteArray()
  14. var res := reader.read_file("hello.txt")
  15. reader.close()
  16. return res
  17. [/codeblock]
  18. </description>
  19. <tutorials>
  20. </tutorials>
  21. <methods>
  22. <method name="close">
  23. <return type="int" enum="Error" />
  24. <description>
  25. Closes the underlying resources used by this instance.
  26. </description>
  27. </method>
  28. <method name="file_exists">
  29. <return type="bool" />
  30. <param index="0" name="path" type="String" />
  31. <param index="1" name="case_sensitive" type="bool" default="true" />
  32. <description>
  33. Returns [code]true[/code] if the file exists in the loaded zip archive.
  34. Must be called after [method open].
  35. </description>
  36. </method>
  37. <method name="get_files">
  38. <return type="PackedStringArray" />
  39. <description>
  40. Returns the list of names of all files in the loaded archive.
  41. Must be called after [method open].
  42. </description>
  43. </method>
  44. <method name="open">
  45. <return type="int" enum="Error" />
  46. <param index="0" name="path" type="String" />
  47. <description>
  48. Opens the zip archive at the given [param path] and reads its file index.
  49. </description>
  50. </method>
  51. <method name="read_file">
  52. <return type="PackedByteArray" />
  53. <param index="0" name="path" type="String" />
  54. <param index="1" name="case_sensitive" type="bool" default="true" />
  55. <description>
  56. Loads the whole content of a file in the loaded zip archive into memory and returns it.
  57. Must be called after [method open].
  58. </description>
  59. </method>
  60. </methods>
  61. </class>