Skip to main content

The "xzip_extract" Function

Syntax#

xzip_extract(arch, dir, file1, [file2], ... );
ArgumentTypeDescription
archstringThe full path and filename of the archive to create
dirstringThe full path of the destination folder to extract into, excluding final slash
file1string/integer/array/keywordThe name or index of a file to extract, or array of files (or keyword 'all' for all files)
[file2]stringOptional: Additional files to extract from the archive (arrays and keywords not accepted)

Description#

Extracts one or more files from an archive created with xzip_create to the destination folder. Also returns true or false to indicate if the operation succeeded.

note

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.

For files stored in the archive, a full path should not be used, just the file name with extension. Use xzip_list to see what file names are available in the archive. The numerical index from xzip_list, an array, or the all keyword can also be used. If a folder is input, all files from the folder will be extracted, preserving the relative path.

Be warned that extraction takes time, and extracting many files at once can cause the game to temporarily appear frozen. It is recommended to extract large archives over a series of Steps and display a loading screen. (See example usage.)

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#

//CREATE
file_archive = "C:\\archive.xz";
file_dest = "C:\\my\\destination\\folder";
file_count = xzip_count(file_archive);
file_current = 0;
file_array = xzip_list(file_archive);
//STEP
if (file_current < file_count) {
xzip_extract(file_archive, file_dest, file_array[file_current]);
file_current++;
}
//DRAW
var file_prog = file_current/file_count;
draw_text(25, 25, "Extraction: " + string(file_prog) + "% complete");