Set of commands implemented in C++ featuring MD5 hash and Zip support.
This plugin currently offers a set of commands to create MD5 hash values, compare files, create Zip files and unpack such files. New commands will be added in the future.
Note: the following descriptions contain examples using local filenames, but you can also use network pathes like “//server/ path/…”.
MD5 Hash commands
[string] KP_Hash_GetMD5 (name[string], isFilename[bool] )
The KP_Hash_GetMD5 command requires two parameters: a string and a boolean value. If the boolean parameter is set to false, the command returns the MD5 hash value of the string parameter. If it is set to true, the string parameter is interpreted as a filename. In this case the command returns the MD5 hash value of the indicated file and an empty string if the filename is invalid.
[boolean] KP_Hash_CompareFiles (filename1[string], filename2[string] )
This command compares the hash values of two files indicated by the two parameters. It returns true if the hash values are equal and false if they are not equal or one or both filenames are invalid.
Zip & Unzip commands
[boolean] KP_Zip_Create (filenames[array], zipFile[string], prefix[string], relativePath[string], password[string] )
This command creates a zip file with the files specified in the filenames array. The first two are the only required parameters.
The prefix parameter is a flexible way to keep a relative path structure in the zip file.
For example if you want to store the file “x:/projects/project1/pictures/image.tif” in a Zip file so that it contains the file in “project1/pictures/image.tif”, just set the prefix parameter to “x:/projects/”. If applicable, this prefix is simply removed from the absolute filenames. If prefix is an empty string, the files are stored in the Zip file without their pathes. To add a new relative path, simply set the relativePath parameter to a directory name of your choice. So to create a structure like “versions/version1/project1/pictures/image.tif” simply set relativePath to “versions/version1″. To encrypt the items in the Zip file set the password parameter to a non empty string. If the command fails to create the Zip file, it returns false and plots error messages.
[boolean] KP_Zip_CreateFromDir ( directory[string], zipFile[string], recursive[boolean], password[string] )
Command to directly pack all files in a directory specified by the directory parameter (must be absolute). The Zip file will be saved at the location indicated by the parameter zipFile. If recursive is set to true, all subdirectories will be included as well (default is false). Set the password parameter to a non empty string to enable encryption.
[boolean] KP_Zip_Extract ( zipFile [string], destinationDirectory [string], password [string] )
With the KP_Zip_Extract command you can unpack a Zip file to a destination directory. You can specify a password if required. The command returns true if all files were extracted successfully, if not it logs an error message and returns false.
Download KP_Tools Add-On for XSI 4.2 and 5.x
Download KP_Tools Add-On for XSI 6.01
version notes:
V1.1: added command KP_Zip_CreateFromDir
requires: min. XSI 4.2 and Windows XP
(The Zip/Unzip commands are using the great Zip-Library from http://www.codeproject.com/file/zip_utils.asp)