ZIPReader
继承: RefCounted < Object
Allows reading the content of a zip file.
描述
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
方法
| 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 ) |
方法说明
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.
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.
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。