ZIPReader.xml 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="ZIPReader" inherits="RefCounted" version="4.0" 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="get_files">
  29. <return type="PackedStringArray" />
  30. <description>
  31. Returns the list of names of all files in the loaded archive.
  32. Must be called after [method open].
  33. </description>
  34. </method>
  35. <method name="open">
  36. <return type="int" enum="Error" />
  37. <param index="0" name="path" type="String" />
  38. <description>
  39. Opens the zip archive at the given [param path] and reads its file index.
  40. </description>
  41. </method>
  42. <method name="read_file">
  43. <return type="PackedByteArray" />
  44. <param index="0" name="path" type="String" />
  45. <param index="1" name="case_sensitive" type="bool" default="true" />
  46. <description>
  47. Loads the whole content of a file in the loaded zip archive into memory and returns it.
  48. Must be called after [method open].
  49. </description>
  50. </method>
  51. </methods>
  52. </class>