ZIPPacker

继承: RefCounted < Object

允许创建 zip 文件。

描述

该类实现了一个写入器,可以将多个 blob 存储在一个压缩文件中。

  1. func write_zip_file():
  2. var writer := ZIPPacker.new()
  3. var err := writer.open("user://archive.zip")
  4. if err != OK:
  5. return err
  6. writer.start_file("hello.txt")
  7. writer.write_file("Hello World".to_utf8_buffer())
  8. writer.close_file()
  9. writer.close()
  10. return OK

方法

Error

close ( )

Error

close_file ( )

Error

open ( String path, ZipAppend append=0 )

Error

start_file ( String path )

Error

write_file ( PackedByteArray data )


枚举

enum ZipAppend:

ZipAppend APPEND_CREATE = 0

在给定的路径新建 Zip 归档文件。

ZipAppend APPEND_CREATEAFTER = 1

在位于给定路径的已有文件的末尾追加新的 Zip 归档文件。

ZipAppend APPEND_ADDINZIP = 2

在位于给定路径的已有 Zip 归档文件中添加新文件。


方法说明

Error close ( )

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


Error close_file ( )

停止向归档中的文件进行写入。

如果没有打开文件,则会失败。


Error open ( String path, ZipAppend append=0 )

打开给定路径处的 Zip 文件,使用指定的写入模式进行写入。

必须在其他调用前调用。


Error start_file ( String path )

开始向存档中的一个文件写入。同一时间只能写一个文件。

必须在open之后调用。


Error write_file ( PackedByteArray data )

将给定的 data 写到文件中。

需要在 start_file 之后调用。

Previous Next


© 版权所有 2014-present Juan Linietsky, Ariel Manzur and the Godot community (CC BY 3.0). Revision b1c660f7.

Built with Sphinx using a theme provided by Read the Docs.