ZIP - inflating and deflating strings and files using zlib and minizip
Thu, 09/18/2008 - 07:39 pm
This XOP is able to inflate and deflate strings and unzip zip archives.
The deflation and inflation of strings is encoded in .z and .gz formats. You can use this to compress strings (or any other data) inside IGOR. By using fbinread you can also zip individual files.
You can also unzip zip archives that contain multiple files.
ZIP is based on the free zlib library (www.zlib.net) and the Minizip code by Gilles Vollant (http://www.winimage.com/zLibDll/minizip.html)
string test = "0123456789" string test2 = zipencode(test) string test3 = zipdecode(test2) print test3
variable fileID open/r fileID //open a .gz file fStatus fileID //get the length of the file in bytes string inData = "" inData = padstring(indata,V_logEOF,0) //make the indata string as long as the fileitself fbinread fileiD, inData //read in the data string unzippedData = zipdecode(inData) //unzip the data in the string close(fileID)
This can be useful for zipping and unzipping waves using the SOCKIT.xop. (This has commands SOCKITstringtoWave and SOCKITwavetostring).
To unzip zip archives use the following code:
ZIPfile/o outputDirStr, sourceZipfileStr
The /O flag means that files extracted from the sourceZipfile will overwrite those already contained in the outputDirectory.
outputDirStr is a string containing the directory location for the extracted files.
sourceZipfileStr is a string containing the location of the zip archive.
Both outputDirStr and sourceZipfileStr must be native file paths, i.e. NOT POSIX.
In addition, all directory structure from the zip file will be lost/flattened.
ZIPfile/o "Macintosh HD:Users:joe:Desktop:", "Macintosh HD:Users:joe:Desktop:data.zip"
Current Project Release
|Version Date:||Fri, 04/06/2018 - 03:11 pm|
Igor Pro 8
Igor XOP Toolkit
Igor NIDAQ Tools MX