Work in progress

Godot documentation is being updated to reflect the latest changes in version 4.0. Some documentation pages may still state outdated information. This banner will tell you if you're reading one of such pages.

The contents of this page are up to date. If you can still find outdated information, please open an issue.

ZIPReader

Inherits: RefCounted < Object

Allows reading the content of a zip file.

Description

This class implements a reader that can extract the content of individual files inside a zip archive.

func read_zip_file():
    var reader := ZIPReader.new()
    var err := reader.open("user://archive.zip")
    if err != OK:
        return PackedByteArray()
    var res := reader.read_file("hello.txt")
    reader.close()
    return res

Methods

Error

close ( )

PackedStringArray

get_files ( )

Error

open ( String path )

PackedByteArray

read_file ( String path, bool case_sensitive=true )


Method Descriptions

Error close ( )

Closes the underlying resources used by this instance.


PackedStringArray get_files ( )

Returns the list of names of all files in the loaded archive.

Must be called after open.


Error open ( String path )

Opens the zip archive at the given path and reads its file index.


PackedByteArray read_file ( String path, bool case_sensitive=true )

Loads the whole content of a file in the loaded zip archive into memory and returns it.

Must be called after open.