ZIPPacker.xml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="ZIPPacker" inherits="RefCounted" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
  3. <brief_description>
  4. Allows the creation of zip files.
  5. </brief_description>
  6. <description>
  7. This class implements a writer that allows storing the multiple blobs in a zip archive.
  8. [codeblock]
  9. func write_zip_file():
  10. var writer := ZIPPacker.new()
  11. var err := writer.open("user://archive.zip")
  12. if err != OK:
  13. return err
  14. writer.start_file("hello.txt")
  15. writer.write_file("Hello World".to_utf8_buffer())
  16. writer.close_file()
  17. writer.close()
  18. return OK
  19. [/codeblock]
  20. </description>
  21. <tutorials>
  22. </tutorials>
  23. <methods>
  24. <method name="close">
  25. <return type="int" enum="Error" />
  26. <description>
  27. Closes the underlying resources used by this instance.
  28. </description>
  29. </method>
  30. <method name="close_file">
  31. <return type="int" enum="Error" />
  32. <description>
  33. Stops writing to a file within the archive.
  34. It will fail if there is no open file.
  35. </description>
  36. </method>
  37. <method name="open">
  38. <return type="int" enum="Error" />
  39. <param index="0" name="path" type="String" />
  40. <param index="1" name="append" type="int" enum="ZIPPacker.ZipAppend" default="0" />
  41. <description>
  42. Opens a zip file for writing at the given path using the specified write mode.
  43. This must be called before everything else.
  44. </description>
  45. </method>
  46. <method name="start_file">
  47. <return type="int" enum="Error" />
  48. <param index="0" name="path" type="String" />
  49. <description>
  50. Starts writing to a file within the archive. Only one file can be written at the same time.
  51. Must be called after [method open].
  52. </description>
  53. </method>
  54. <method name="write_file">
  55. <return type="int" enum="Error" />
  56. <param index="0" name="data" type="PackedByteArray" />
  57. <description>
  58. Write the given [param data] to the file.
  59. Needs to be called after [method start_file].
  60. </description>
  61. </method>
  62. </methods>
  63. <constants>
  64. <constant name="APPEND_CREATE" value="0" enum="ZipAppend">
  65. Create a new zip archive at the given path.
  66. </constant>
  67. <constant name="APPEND_CREATEAFTER" value="1" enum="ZipAppend">
  68. Append a new zip archive to the end of the already existing file at the given path.
  69. </constant>
  70. <constant name="APPEND_ADDINZIP" value="2" enum="ZipAppend">
  71. Add new files to the existing zip archive at the given path.
  72. </constant>
  73. </constants>
  74. </class>