Up to date

This page is up to date for Godot 4.3. If you still find outdated information, please open an issue.

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.

func write_zip_file():
    var writer := ZIPPacker.new()
    var err := writer.open("user://archive.zip")
    if err != OK:
        return err
    writer.start_file("hello.txt")
    writer.write_file("Hello World".to_utf8_buffer())
    writer.close_file()

    writer.close()
    return OK

MethodsΒΆ

Error

close()

Error

close_file()

Error

open(path: String, append: ZipAppend = 0)

Error

start_file(path: String)

Error

write_file(data: PackedByteArray)


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(path: String, append: ZipAppend = 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(path: String) πŸ”—

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(data: PackedByteArray) πŸ”—

Write the given data to the file.

Needs to be called after start_file.