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.

  1. func read_zip_file():
  2. var reader := ZIPReader.new()
  3. var err := reader.open("user://archive.zip")
  4. if err != OK:
  5. return PackedByteArray()
  6. var res := reader.read_file("hello.txt")
  7. reader.close()
  8. return res

Methods

Error

close()

bool

file_exists(path: String, case_sensitive: bool = true)

PackedStringArray

get_files()

Error

open(path: String)

PackedByteArray

read_file(path: String, case_sensitive: bool = true)


Method Descriptions

Error close() 🔗

Closes the underlying resources used by this instance.


bool file_exists(path: String, case_sensitive: bool = true) 🔗

Returns true if the file exists in the loaded zip archive.

Must be called after open.


PackedStringArray get_files() 🔗

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

Must be called after open.


Error open(path: String) 🔗

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


PackedByteArray read_file(path: String, case_sensitive: bool = true) 🔗

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

Must be called after open.


User-contributed notes

Please read the User-contributed notes policy before submitting a comment.

Previous Next