Skip to main content

The "xzip_write" Function

Syntax#

xzip_write(arch, buff, file);
ArgumentTypeDescription
archstringThe full path and filename of the archive to check
buffbufferA buffer containing data to be written to the archive
filestringThe file name to assign to the buffer in the archive (including relative path, if any)

Description#

Writes data from a buffer directly into the archive (instead of from a file on the disk) and assigns it a standard file name. Buffers will be compressed with zlib before writing. Once written, buffers can be restored with xzip_read or extracted and read from disk like any other file.

Also returns true or false to indicate if the operation succeeded. Note that this includes failure to overwrite a file flagged as read-only. (This can be determined with xzip_get_readonly.)

In GameMaker Studio, buffers are simply containers for binary data, and can store anything from text, to audio, to surfaces, and beyond. However, it's important to keep in mind that GameMaker must have a function to interpret the data in order to use it.

Example#

var buf_surf = buffer_create(32, buffer_grow, 1);
buffer_get_surface(buf_surf, application_surface, 0);
xzip_write("C:\\archive.xz", buf_surf, "file5.surf");

This will copy the application surface in its current state and write it to the archive, essentially capturing a screenshot which can be viewed later.