ZIPPacker.xml 2.6 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. See also [ZIPReader] and [PCKPacker].
  8. [codeblock]
  9. # Create a ZIP archive with a single file at its root.
  10. func write_zip_file():
  11. var writer = ZIPPacker.new()
  12. var err = writer.open("user://archive.zip")
  13. if err != OK:
  14. return err
  15. writer.start_file("hello.txt")
  16. writer.write_file("Hello World".to_utf8_buffer())
  17. writer.close_file()
  18. writer.close()
  19. return OK
  20. [/codeblock]
  21. </description>
  22. <tutorials>
  23. </tutorials>
  24. <methods>
  25. <method name="close">
  26. <return type="int" enum="Error" />
  27. <description>
  28. Closes the underlying resources used by this instance.
  29. </description>
  30. </method>
  31. <method name="close_file">
  32. <return type="int" enum="Error" />
  33. <description>
  34. Stops writing to a file within the archive.
  35. It will fail if there is no open file.
  36. </description>
  37. </method>
  38. <method name="open">
  39. <return type="int" enum="Error" />
  40. <param index="0" name="path" type="String" />
  41. <param index="1" name="append" type="int" enum="ZIPPacker.ZipAppend" default="0" />
  42. <description>
  43. Opens a zip file for writing at the given path using the specified write mode.
  44. This must be called before everything else.
  45. </description>
  46. </method>
  47. <method name="start_file">
  48. <return type="int" enum="Error" />
  49. <param index="0" name="path" type="String" />
  50. <description>
  51. Starts writing to a file within the archive. Only one file can be written at the same time.
  52. Must be called after [method open].
  53. </description>
  54. </method>
  55. <method name="write_file">
  56. <return type="int" enum="Error" />
  57. <param index="0" name="data" type="PackedByteArray" />
  58. <description>
  59. Write the given [param data] to the file.
  60. Needs to be called after [method start_file].
  61. </description>
  62. </method>
  63. </methods>
  64. <constants>
  65. <constant name="APPEND_CREATE" value="0" enum="ZipAppend">
  66. Create a new zip archive at the given path.
  67. </constant>
  68. <constant name="APPEND_CREATEAFTER" value="1" enum="ZipAppend">
  69. Append a new zip archive to the end of the already existing file at the given path.
  70. </constant>
  71. <constant name="APPEND_ADDINZIP" value="2" enum="ZipAppend">
  72. Add new files to the existing zip archive at the given path.
  73. </constant>
  74. </constants>
  75. </class>