The "xzip_read" Function

Syntax

xzip_read(arch, file);
ArgumentTypeDescription
archstringThe full path and filename of the archive to read from
filestring/integerThe name or index of a file to read

Description

Reads a file from an archive directly into memory (instead of extracting to the disk) and returns the result as a buffer. This is especially useful for game data like audio and surfaces which have built-in buffer functions in GameMaker Studio.

If the input archive or file within do not exist, -1 will be returned instead, so it's a good idea to run buffer_exists before handling data returned by this script.

Example

var buf_surf = xzip_read("C:\\archive.xz", "file5.surf");
var my_surf = surface_create(1280, 720);
if (buffer_exists(buf_surf)) {
buffer_set_surface(buf_surf, my_surf, 0, 0, 0);
}

This will load a surface from an archive and copy it to a pre-existing surface for drawing.