Skip to main content

The "xzip_create" Function

Syntax#

xzip_create(arch, file1, [file2], ...);
ArgumentTypeDescription
archstringThe full path and filename of the archive to create
file1string/arrayThe full path and filename of a file to add to the archive, or array of file paths
[file2]stringOptional: Additional files to add to the archive (arrays not accepted)

Description#

Creates a new Xzip archive on the disk with the specified filename and adds one or more files to it. Also returns the archive path as a string to be stored in a variable for future reference.

Input files should be written as a string containing the full path of the file to add, including drive letter. If a path points to a folder, the contents of the folder will be added, preserving the relative path of files and subfolders inside.

warning

At present, Xzip requires all files to have an extension. Also, although folders are supported, no two files can have the exact same file name even if they are separated by different folders!

important

Due to GameMaker's string handling, slashes in paths should be escaped (i.e. \\, not \). Do not add a final slash to directories!

Instead of listing individual files in the xzip_create command, an array of file paths can be passed into the file1 argument instead. Only the first file argument will accept an array as input, and once detected, no further file arguments will be processed. You cannot combine array and string inputs in a single command.

Files added to the archive will be compressed using zlib. However, Xzip uses additional metadata which may result in compressed files not being much smaller than their uncompressed originals. This is normal.

The resulting archive can be added to the game's Included Files area as a means of storing external assets for future use. To access files in the created archive, use xzip_extract or xzip_read.

Be warned that creation takes time, and archiving many files at once can cause the game to temporarily appear frozen.

tip

It is recommended to disable the filesystem sandbox for this script. If the sandbox is enabled, archives can only be created and extracted in working_directory.

Example#

my_zip = xzip_create(
//Archive
"C:\\archive.xz",
//Files
"C:\\file1.txt",
"C:\\file2.gif",
"C:\\file3.png"
);