Skip to main content

ModZipReader

See the code at utils/zip_reader.gd

Description

Inherits ZIPReader

This class is an extension of the native Godot ZIPReader. It handles reading files and resources from inside ZIPs.


Signals

None


Properties

None


Methods

read

static func read(path: String, callback: Callable) -> unknown:

Opens a ZIP file and handles the contents.

Note: This is a static function and should be called directly on ModZipReader.

Parameters

NameTypeDescription
pathStringThe path to the ZIP to open.
callbackCallable
Should accept two arguments:
  1. reader: ModZipReader
  2. paths: PackedStringArray
Can return anything.
After opening the ZIP, this function will be called with arguments:
  1. self
  2. The result of ZIPReader.get_files()

Returns

Typeunknown
Defaultvoid
DescriptionWill return the result of the callback function.

exists

func exists(path: String) -> bool

Checks if a file exists at the given path inside the opened ZIP.

Parameters

NameTypeDescription
pathStringThe path to check.

Returns

Typebool
Descriptiontrue if there is a non-empty file at the given path.

read_string

func read_string(path: String) -> String

Reads the contents of the file at the given path as a String.

Parameters

NameTypeDescription
pathStringThe path to read from.

Returns

TypeString
DescriptionThe contents of the file.

read_resource

func read_resource(path: String) -> Resource

Reads the contents of the file at the given path as a Resource.

Parameters

NameTypeDescription
pathStringThe path to read from.

Returns

TypeResource
DescriptionThe resource at the given path.

read_script

func read_script(path: String) -> GDScript

Reads the contents of the file at the given path as a GDScript.

Parameters

NameTypeDescription
pathStringThe path to read from.

Returns

TypeGDScript
DescriptionThe script at the given path.

read_json

func read_json(path: String) -> Dictionary

Reads the contents of the file at the given path as a JSON Dictionary.

Parameters

NameTypeDescription
pathStringThe path to read from.

Returns

TypeDictionary
DescriptionThe JSON at the given path.

read_image

func read_image(path: String) -> ImageTexture

Reads the contents of the file at the given path as an ImageTexture.

Parameters

NameTypeDescription
pathStringThe path to read from.

Returns

TypeImageTexture
DescriptionThe image at the given path.