Table of Contents

Class ZIPPacker

Allows the creation of ZIP files.

Inheritance
ZIPPacker

Remarks

This class implements a writer that allows storing the multiple blobs in a ZIP archive. See also ZIPReader and PCKPacker.

# Create a ZIP archive with a single file at its root.
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

close

Closes the underlying resources used by this instance.

int close

close_file

Stops writing to a file within the archive.

It will fail if there is no open file.

int close_file

open(String, int)

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

This must be called before everything else.

int open(String path, int append)

Parameters

path String
append int

start_file(String)

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

Must be called after ZIPPacker.open.

int start_file(String path)

Parameters

path String

write_file(PackedByteArray)

Write the given data to the file.

Needs to be called after ZIPPacker.start_file.

int write_file(PackedByteArray data)

Parameters

data PackedByteArray