Skip to main content

The "xzip_add" Function


xzip_add(arch, file1, [file2], ...);
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)


Adds one or more files to an archive previously created with xzip_create. Also returns true or false to indicate if the operation succeeded or failed. Note that this includes failure to overwrite an existing file flagged as read-only. (This can be determined with xzip_get_readonly.)


If multiple files are input, even a single error will return false even though other files succeeded. In this scenario, use xzip_report to retrieve a list of failed files.

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.


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!


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

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


xzip_add("C:\\archive.xz", "C:\\file4.jpg", "C:\\file5.pdf", "C:\\my\\source\\folder");