Skip to content

Create script API for reading and writing zip files

James Westman requested to merge github/fork/flyingpimonster/zip-module into master

This builds on #22554, which only supported writing zip files.

Creates two new classes, ZipReader and ZipWriter, for reading and writing zip files in GDScript using the already bundled minizip library.

Example:

var w := ZipWriter.new()
w.open("user://test.zip")
w.start_file("hello/world.txt")
w.write_file("Hello, world!".to_utf8())
w.close()

var r := ZipReader.new()
r.open("user://test.zip")
for filename in r.get_files():
    print(filename, ": ", r.read_file(filename).get_string_from_utf8())

Note: Append modes don't work yet due to a bug in core/io/zip_io.cpp. The zipio_open function doesn't properly handle the ZLIB_FILEFUNC_MODE_EXISTING flag. I'll fix that in another PR.

Merge request reports