Class reference

ZIPPacker

Inherits RefCounted

Allows the creation of ZIP files.

Description

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
		

Properties

Methods

int close()

Closes the underlying resources used by this instance.

int close_file()

Stops writing to a file within the archive. It will fail if there is no open file.

int open(String path, int append = 0)

Opens a zip file for writing at the given path using the specified write mode. This must be called before everything else.

int start_file(String path)

Starts writing to a file within the archive. Only one file can be written at the same time. Must be called after open().

Constants

APPEND_CREATE = 0

Enum: ZipAppend

Create a new zip archive at the given path.

APPEND_CREATEAFTER = 1

Enum: ZipAppend

Append a new zip archive to the end of the already existing file at the given path.

APPEND_ADDINZIP = 2

Enum: ZipAppend

Add new files to the existing zip archive at the given path.

COMPRESSION_DEFAULT = -1

Enum: CompressionLevel

Start a file with the default Deflate compression level (6). This is a good compromise between speed and file size.

COMPRESSION_NONE = 0

Enum: CompressionLevel

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).

COMPRESSION_FAST = 1

Enum: CompressionLevel

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.

COMPRESSION_BEST = 9

Enum: CompressionLevel

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.

Source revision 5592dc3a7a61
Connection interrupted. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.