ZIPPacker
繼承: RefCounted < Object
Allows the creation of ZIP files.
說明
This class implements a writer that allows storing the multiple blobs in a ZIP archive. See also ZIPReader and PCKPacker.
# Create a ZIP archive with a single file at its root.
func write_zip_file():
var writer = ZIPPacker.new()
var err = writer.open("user://archive.zip")
if err != OK:
return err
writer.start_file("hello.txt")
writer.write_file("Hello World".to_utf8_buffer())
writer.close_file()
writer.close()
return OK
屬性
|
方法
close() |
|
start_file(path: String) |
|
write_file(data: PackedByteArray) |
列舉
enum ZipAppend: 🔗
ZipAppend APPEND_CREATE = 0
在給定的路徑新建 Zip 歸檔檔。
ZipAppend APPEND_CREATEAFTER = 1
在位於給定路徑的已有檔的末尾追加新的 Zip 歸檔檔。
ZipAppend APPEND_ADDINZIP = 2
在位於給定路徑的已有 Zip 歸檔檔中新增新檔。
enum CompressionLevel: 🔗
CompressionLevel COMPRESSION_DEFAULT = -1
Start a file with the default Deflate compression level (6). This is a good compromise between speed and file size.
CompressionLevel COMPRESSION_NONE = 0
Start a file with no compression. This is also known as the "Store" compression mode and is the fastest method of packing files inside a ZIP archive. Consider using this mode for files that are already compressed (such as JPEG, PNG, MP3, or Ogg Vorbis files).
CompressionLevel COMPRESSION_FAST = 1
Start a file with the fastest Deflate compression level (1). This is fast to compress, but results in larger file sizes than COMPRESSION_DEFAULT. Decompression speed is generally unaffected by the chosen compression level.
CompressionLevel COMPRESSION_BEST = 9
Start a file with the best Deflate compression level (9). This is slow to compress, but results in smaller file sizes than COMPRESSION_DEFAULT. Decompression speed is generally unaffected by the chosen compression level.
屬性說明
The compression level used when start_file() is called. Use CompressionLevel as a reference.
方法說明
關閉該實例底層所使用的資源。
停止向歸檔中的檔進行寫入。
如果沒有打開檔,則會失敗。
Error open(path: String, append: ZipAppend = 0) 🔗
打開給定路徑處的 Zip 檔,使用指定的寫入模式進行寫入。
必須在其他呼叫前呼叫。
Error start_file(path: String) 🔗
開始向存檔中的一個檔寫入。同一時間只能寫一個檔。
必須在open()之後呼叫。
Error write_file(data: PackedByteArray) 🔗
將給定的 data 寫到檔案中。
需要在 start_file() 之後呼叫。