Skip to main content

The "xzip_list_dir" Function

Syntax#

xzip_list_dir(arch, dir, [relative]);
ArgumentTypeDescription
archstringThe full path and filename of the archive to check
dirstringThe relative directory within the archive to list
[relative]booleanOptional: Enables or disables including relative paths in the results (disabled by default)

Description#

Returns an array of strings containing the file names and extensions (and optionally, relative paths) contained within an individual directory within the given archive. An empty directory will return 0, or -1 if the archive doesn't exist at all.

Unlike file names and other directories, dir here should be written as a relative path. (i.e. If the directory is a subfolder, all parent folders must be included in the argument.)

As archives have no mount point, you should not supply a drive letter or leading slash when specifying a directory to list. Use "" to list files in the root directory of the archive.

important

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

Unlike xzip_list, the resulting array indices do not correspond to archive indices. However, many functions support inputting an array of files, in which case an array returned by this function can be passed in directly.

tip

By default, only the contents of the exact folder specified will be listed. To include the contents of any subfolders as well, see xzip_recurse.

Example#

file_dir_array = xzip_list_dir("C:\\archive.xz", "my\\sub\\folder");
xzip_extract("C:\\archive.xz", "C:\\extracted", file_dir_array[0]);

This will retrieve a list of files contained in a specific subfolder of an archive and extract the first file in the list.