/* $DOC$ $NAME$ hb_SetZipComment() $CATEGORY$ Zip Functions $ONELINER$ Set an Zip archive Comment $SYNTAX$ hb_SetZipComment( ) --> NIL $ARGUMENTS$ Comment to add to the zip archive $RETURNS$ this function always return NIL $DESCRIPTION$ This function stored an global comment to an zip archive. It should be called before any of the compression functions. $EXAMPLES$ hb_SetZipComment( "This is an Test" ) hb_ZipFile( "test.zip", { "ios.ini", "win.ini" } ) $STATUS$ R $COMPLIANCE$ This function is a Harbour extension $PLATFORMS$ All $FILES$ Library is hbziparc $END$ */ /* $DOC$ $NAME$ hb_GetZipComment() $CATEGORY$ Zip Functions $ONELINER$ Return the comment of an zip file $SYNTAX$ hb_GetZipComment( ) --> $ARGUMENTS$ File to get the comment from $RETURNS$ The comment that was stored in $DESCRIPTION$ This function receives a valid zip file name as parameter, and returns the global comment stored within. $EXAMPLES$ ? "The comment in test.zip is ", hb_GetZipComment( "test.zip" ) $STATUS$ R $COMPLIANCE$ This function is a Harbour extension $PLATFORMS$ All $FILES$ Library is hbziparc $END$ */ /* $DOC$ $NAME$ hb_ZipTestPK() $CATEGORY$ Zip Functions $ONELINER$ Test pkSpanned zip files $SYNTAX$ hb_ZipTestPK( ) --> $ARGUMENTS$ File to be tested. $RETURNS$ A code that tells if the current disk is the last of a pkSpanned disk set. $DESCRIPTION$ This function tests if the disk inserted is the last disk of an backup set or not. It will return the follow return code when an error is found Error code Meaning 114 Incorrect Disk 103 No Call back was set with hb_ZipTestPK()
Call this function to determine if the disk inserted is the correct one before any other function. $EXAMPLES$ IF hb_ZipTestPK( "test22.zip" ) == 114 ? "Invalid Diskette" ENDIF $STATUS$ R $COMPLIANCE$ This function is a Harbour extension $PLATFORMS$ All $FILES$ Library is hbziparc $END$ */ /* $DOC$ $NAME$ hb_SetDiskZip() $CATEGORY$ Zip Functions $ONELINER$ Set an codeblock for disk changes $SYNTAX$ hb_SetDiskZip( ) --> .T. $ARGUMENTS$ an Code block that contains an function that will be performed when the need of changing disk are need. $RETURNS$ It always returns True $DESCRIPTION$ This function will set an codeblock that will be evaluated every time that an changedisk event is necessary. receives nDisk as a code block param that corresponds to the diskette number to be processed. Set this function before opening archives that are in removable media. This block will be released, when the caller finish it job. $EXAMPLES$ hb_SetDiskZip( {| nDisk | Alert( "Please insert disk no " + hb_ntos( nDisk ) ) } ) $COMPLIANCE$ This function is a Harbour extension $PLATFORMS$ All $FILES$ Library is hbziparc $END$ */ /* $DOC$ $NAME$ hb_SetBuffer() $CATEGORY$ Zip Functions $ONELINER$ $SYNTAX$ hb_SetBuffer( [], [], [] ) --> NIL $ARGUMENTS$ The size of the write buffer. The size of the extract buffer. The size of the read buffer. $RETURNS$ This function always returns NIL. $DESCRIPTION$ This function set the size of the internal buffers for write/extract/read operation. If the size of the buffer is smaller then the default, the function will automatically use the default values, which are 65535/16384/32768 respectively. This function be called before any of the compression/decompression functions. $EXAMPLES$ hb_SetBuffer( 100000, 115214, 65242 ) $STATUS$ R $COMPLIANCE$ This function is a Harbour extension $PLATFORMS$ All $FILES$ Library is hbziparc $END$ */ /* $DOC$ $NAME$ hb_ZipFileByTDSpan() $CATEGORY$ Zip Functions $ONELINER$ Create a zip file $SYNTAX$ hb_ZipFileByTDSpan( , | , , , , , , , , ) --> lCompress $ARGUMENTS$ Name of the zip file Name of a file to Compress, Drive and/or path can be used _or_ An array containing files to compress, Drive and/or path can be used Compression level ranging from 0 to 9 Code block to execute while compressing Toggle to overwrite the file if exists Password to encrypt the files Size of the archive, in bytes. Default is 1457664 bytes Toggle to store the path or not Toggle to store the Drive letter and path or not Code block for File Progress $RETURNS$ .T. if file was create, otherwise .F. $DESCRIPTION$ This function creates a zip file named . If the extension is omitted, .zip will be assumed. If the second parameter is a character string, this file will be added to the zip file. If the second parameter is an array, all file names contained in will be compressed. If is used, it determines the compression type where 0 means no compression and 9 means best compression. If is used, every time the file is opened to compress it will evaluate bBlock. Parameters of bBlock are cFile and nPos. If is used, it toggles to overwrite or not the existing file. Default is to overwrite the file, otherwise if is false the new files are added to the . If is used, it tells thats the path should also be stored with the file name. Default is false. If is used, it tells thats the Drive and path should also be stored with the file name. Default is false. If is used, an Code block is evaluated, showing the total of that file has being processed. The codeblock must be defined as follow {| nPos, nTotal | GaugeUpdate( aGauge1, nPos / nTotal ) } $EXAMPLES$ PROCEDURE Main() IF hb_ZipFileByTDSpan( "test.zip", "test.prg" ) ? "File was successfully created" ENDIF IF hb_ZipFileByTDSpan( "test1.zip", { "test.prg", "test.hbp" } ) ? "File was successfully created" ENDIF IF hb_ZipFileByTDSpan( "test2.zip", { "test.prg", "test.hbp" }, 9, {| nPos, cFile | QOut( cFile ) }, "hello",, 521421 ) ? "File was successfully created" ENDIF aFiles := { "test.prg", "test.hbp" } nLen := Len( aFiles ) aGauge := GaugeNew( 5, 5, 7, 40, "W/B", "W+/B", "." ) GaugeDisplay( aGauge ) hb_ZipFileByTDSpan( "test33.zip", aFiles, 9, {| cFile, nPos | GaugeUpdate( aGauge, nPos / nLen ) },, "hello",, 6585452 ) RETURN $STATUS$ R $COMPLIANCE$ This function is a Harbour extension $PLATFORMS$ All $FILES$ Library is hbziparc $END$ */ /* $DOC$ $NAME$ hb_ZipFileByPKSpan() $CATEGORY$ Zip Functions $ONELINER$ Create a zip file on removable media $SYNTAX$ hb_ZipFileByPKSpan( , | , , , , , , , ) --> lCompress $ARGUMENTS$ Name of the zip file Name of a file to Compress, Drive and/or path can be used _or_ An array containing files to compress, Drive and/or path can be used Compression level ranging from 0 to 9 Code block to execute while compressing Toggle to overwrite the file if exists Password to encrypt the files Toggle to store the path or not Toggle to store the Drive letter and path or not Code block for File Progress $RETURNS$ .T. if file was create, otherwise .F. $DESCRIPTION$ This function creates a zip file named . If the extension is omitted, .zip will be assumed. If the second parameter is a character string, this file will be added to the zip file. If the second parameter is an array, all file names contained in will be compressed. Also, the use of this function is for creating backup in removable media like an floppy drive/zip drive. If is used, it determines the compression type where 0 means no compression and 9 means best compression. If is used, every time the file is opened to compress it will evaluate bBlock. Parameters of bBlock are cFile and nPos. If is used , it toggles to overwrite or not the existing file. Default is to overwrite the file, otherwise if is false the new files are added to the . If is used, all files that are added to the archive are encrypted with the password. If is used, it tells thats the path should also be stored with the file name. Default is false. If is used, it tells thats the Drive and path should also be stored with the file name. Default is false. If is used, an Code block is evaluated, showing the total of that file has being processed. The codeblock must be defined as follow {| nPos, nTotal | GaugeUpdate( aGauge1, nPos / nTotal ) } Before calling this function, Set an Changedisk codeblock by calling the hb_SetDiskZip(). $EXAMPLES$ PROCEDURE Main() hb_SetDiskZip( {| nDisk | Alert( "Please insert disk no " + hb_ntos( nDisk ) ) } ) IF hb_ZipFileByPKSpan( "test.zip", "test.prg" ) ? "File was successfully created" ENDIF IF hb_ZipFileByPKSpan( "test1.zip", { "test.prg", "test.hbp" } ) ? "File was successfully created" ENDIF IF hb_ZipFileByPKSpan( "test2.zip", { "test.prg", "test.hbp" }, 9, {| nPos, cFile | QOut( cFile ) } ) ? "File was successfully created" ENDIF aFiles := { "test.prg", "test.hbp" } nLen := Len( aFiles ) aGauge := GaugeNew( 5, 5, 7, 40, "W/B", "W+/B", "." ) GaugeDisplay( aGauge ) hb_ZipFileByPKSpan( "test33.zip", aFiles, 9, {| cFile, nPos | GaugeUpdate( aGauge, nPos / nLen ) },, "hello" ) RETURN $STATUS$ R $COMPLIANCE$ This function is a Harbour extension $PLATFORMS$ All $FILES$ Library is hbziparc $END$ */ /* $DOC$ $NAME$ hb_ZipFile() $CATEGORY$ Zip Functions $ONELINER$ Create a zip file $SYNTAX$ hb_ZipFile( , | , , , , , , , ) --> lCompress $ARGUMENTS$ Name of the zip file to create Name of a file to Compress, Drive and/or path can be used _or_ An array containing files to compress, Drive and/or path can be used Compression level ranging from 0 to 9 Code block to execute while compressing Toggle to overwrite the file if exists Password to encrypt the files Toggle to store the path or not Toggle to store the Drive letter and path or not Code block for File Progress $RETURNS$ .T. if file was create, otherwise .F. $DESCRIPTION$ This function creates a zip file named . If the extension is omitted, .zip will be assumed. If the second parameter is a character string, this file will be added to the zip file. If the second parameter is an array, all file names contained in will be compressed. If is used, it determines the compression type where 0 means no compression and 9 means best compression. If is used, every time the file is opened to compress it will evaluate bBlock. Parameters of bBlock are cFile and nPos. If is used, it toggles to overwrite or not the existing file. Default is to overwrite the file, otherwise if is false the new files are added to the . If is used, all files that are added to the archive are encrypted with the password. If is used, it tells the path should also be stored with the file name. Default is false. If is used, it tells thats the Drive and path should also be stored with the file name. Default is false. If is used, an Code block is evaluated, showing the total of that file has being processed. The codeblock must be defined as follow {| nPos, nTotal | GaugeUpdate( aGauge1, nPos / nTotal ) } $EXAMPLES$ PROCEDURE Main() IF hb_ZipFile( "test.zip", "test.prg" ) ? "File was successfully created" ENDIF IF hb_ZipFile( "test1.zip", { "test.prg", "test.hbp" } ) ? "File was successfully created" ENDIF IF hb_ZipFile( "test2.zip", { "test.prg", "test.hbp" }, 9, {| cFile, nPos | QOut( cFile ) } ) ? "File was successfully created" ENDIF aFiles := { "test.prg", "test.hbp" } nLen := Len( aFiles ) aGauge := GaugeNew( 5, 5, 7, 40, "W/B", "W+/B" , "." ) GaugeDisplay( aGauge ) hb_ZipFile( "test33.zip", aFiles, 9, {| cFile, nPos | GaugeUpdate( aGauge, nPos / nLen ) },, "hello" ) RETURN $STATUS$ R $COMPLIANCE$ This function is a Harbour extension $PLATFORMS$ All $FILES$ Library is hbziparc $END$ */ /* $DOC$ $NAME$ hb_UnzipFile() $CATEGORY$ Zip Functions $ONELINER$ Unzip a compressed file $SYNTAX$ hb_UnzipFile( , , , , , | , ) --> lCompress $ARGUMENTS$ Name of the zip file to extract Code block to execute while extracting Toggle to create directory if needed Password to use to extract files Path to extract the files to - mandatory | A File or Array of files to extract - mandatory Code block for File Progress $RETURNS$ .T. if all file was successfully restored, otherwise .F. $DESCRIPTION$ This function restores all files contained inside the . If the extension is omitted, .zip will be assumed. If a file already exists, it will be overwritten. If is used, every time the file is opened to compress it will evaluate bBlock. Parameters of bBlock are cFile and nPos. The is a mandatory parameter. Set to ".\" to extract to the current directory If or are not provided, no files will be extracted! Make sure you provide the file or files you want extracted If is used, an Code block is evaluated, showing the total of that file has being processed. The codeblock must be defined as follow {| nPos, nTotal | GaugeUpdate( aGauge1, nPos / nTotal ) } $EXAMPLES$ PROCEDURE Main() LOCAL aExtract aExtract := hb_GetFilesInZip( "test.zip" ) // extract all files in zip IF hb_UnzipFile( "test.zip",,,, "." + hb_ps(), aExtract ) ? "File was successfully extracted" ENDIF aExtract := hb_GetFilesInZip( "test2.zip" ) // extract all files in zip IF hb_UnzipFile( "test2.zip", {| cFile | QOut( cFile ) },,, "." + hb_ps(), aExtract ) ? "File was successfully extracted" ENDIF RETURN $STATUS$ R $COMPLIANCE$ This function is a Harbour extension $PLATFORMS$ All $FILES$ Library is hbziparc $END$ */ /* $DOC$ $NAME$ hb_ZipDeleteFiles() $CATEGORY$ Zip Functions $ONELINER$ Delete files from an zip archive $SYNTAX$ hb_ZipDeleteFiles( , | | ) --> $ARGUMENTS$ The name of the zip files from where the files will be deleted An File to be removed _or_ An Array of Files to be removed _or_ The Position of the file to be removed $RETURNS$ If the files are deleted, it will return .T.; otherwise it will return .F. in the following cases: Spanned Archives; the file(s) could not be found in the zip file. $DESCRIPTION$ This function removes files from an Zip archive. $EXAMPLES$ ? "has the file zipnew.i been deleted ", iif( hb_ZipDeleteFiles( "test23.zip", "zipnew.i" ), "Yes", "No" ) $STATUS$ R $COMPLIANCE$ This function is a Harbour extension $PLATFORMS$ All $FILES$ Library is hbziparc $END$ */