ZIPPacker

Inherits: RefCounted < Object

Allows the creation of zip files.

Description

This class implements a writer that allows storing the multiple blobs in a zip archive.

  1. func write_zip_file():
  2. var writer := ZIPPacker.new()
  3. var err := writer.open("user://archive.zip")
  4. if err != OK:
  5. return err
  6. writer.start_file("hello.txt")
  7. writer.write_file("Hello World".to_utf8_buffer())
  8. writer.close_file()
  9. writer.close()
  10. return OK

Methods

Error

close ( )

Error

close_file ( )

Error

open ( String path, ZipAppend append=0 )

Error

start_file ( String path )

Error

write_file ( PackedByteArray data )


Enumerations

enum ZipAppend:

ZipAppend APPEND_CREATE = 0

Create a new zip archive at the given path.

ZipAppend APPEND_CREATEAFTER = 1

Append a new zip archive to the end of the already existing file at the given path.

ZipAppend APPEND_ADDINZIP = 2

Add new files to the existing zip archive at the given path.


Method Descriptions

Error close ( )

Closes the underlying resources used by this instance.


Error close_file ( )

Stops writing to a file within the archive.

It will fail if there is no open file.


Error open ( String path, ZipAppend append=0 )

Opens a zip file for writing at the given path using the specified write mode.

This must be called before everything else.


Error start_file ( String path )

Starts writing to a file within the archive. Only one file can be written at the same time.

Must be called after open.


Error write_file ( PackedByteArray data )

Write the given data to the file.

Needs to be called after start_file.

Previous Next


© Copyright 2014-present Juan Linietsky, Ariel Manzur and the Godot community (CC BY 3.0). Revision 53e837c6.

Built with Sphinx using a theme provided by Read the Docs.