Up to date

This page is up to date for Godot 4.2. 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 ( 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