The "xzip_verify" Function
#
SyntaxArgument | Type | Description |
---|---|---|
arch | string | The full path and filename of the archive to check |
dir | string | The full path of the destination folder to check, excluding final slash |
file | string/integer | The name or index of a file to check |
#
DescriptionVerifies an extracted file against its original archive and returns true
or false
if the files' data matches. This is useful not only to test for file corruption or incomplete extraction, but also to protect file integrity. If a file has been illegitimately modified, this script can be used to detect it and trigger re-extraction of the unmodified file from the archive.
tip
To take security one step further, use GameMaker Studio's built-in MD5 functions to store a hash of the archive itself. Then your code can detect if illegitimate modifications have been made to the archive source file in an attempt to thwart xzip_verify
.
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
can also be used.
This function does not support folders as file inputs. Any relative paths inside the archive will be automatically applied to file names. Likewise, the archive file name will be automatically applied to the target directory to check. (Using a directory instead of explicit file names to compare enables simpler batch verifications.)
Be warned that verification takes time, and verifying many files at once can cause the game to temporarily appear frozen. It is recommended to verify large archives over a series of Steps and display a loading screen. (See example usage.)