Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

ZIPReader

继承: RefCounted < Object

允许读取 zip 文件的内容。

描述

该类实现了一个可以提取 zip 存档中各个文件内容的读取器。

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

方法

Error

close ( )

bool

file_exists ( String path, bool case_sensitive=true )

PackedStringArray

get_files ( )

Error

open ( String path )

PackedByteArray

read_file ( String path, bool case_sensitive=true )


方法说明

Error close ( )

关闭该实例底层所使用的资源。


bool file_exists ( String path, bool case_sensitive=true )

如果加载的 zip 存档中存在对应的文件,则返回 true

必须在 open 之后调用。


PackedStringArray get_files ( )

返回加载的存档中所有文件的名称列表。

必须在 open 之后调用。


Error open ( String path )

打开给定 path 的压缩文件,并读取其文件索引。


PackedByteArray read_file ( String path, bool case_sensitive=true )

将加载的 zip 存档中文件的全部内容加载到内存中并返回它。

必须在 open 之后调用。