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.
bBlock a codeblock 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 a codeblock that will be evaluated every time that an change-disk event is necessary. bBlock receives nDisk as a codeblock 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 ) ) } )
cFile | aFiles A File or Array of files to extract - mandatory
pFileProgress Codeblock for File Progress
Returns
lCompress.T. if all file was successfully restored, otherwise .F.
Description
This function restores all files contained inside the cFile. If the extension is omitted, .zip will be assumed. If a file already exists, it will be overwritten.
If bBlock is used, every time the file is opened to compress it will evaluate bBlock. Parameters of bBlock are cFile and nPos.
The cPath is a mandatory parameter. Set to ./ to extract to the current directory.
If cFile or aFiles are not provided, no files will be extracted! Make sure you provide the file or files you want extracted.
If pFileProgress is used, a codeblock is evaluated, showing the total of that file has being processed. The codeblock must be defined as: {| nPos, nTotal | GaugeUpdate( aGauge1, nPos / nTotal ) }
Examples
LOCAL aExtract := hb_GetFilesInZip( "test.zip" ) // extract all files in zip
IF hb_UnzipFile( "test.zip",,,, hb_DirSepToOS( "./" ), 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_DirSepToOS( "./" ), aExtract )
? "File was successfully extracted"
ENDIF
cFile The name of the zip files from where the files will be deleted
cFiletoDelete An File to be removed
or
aFiles An Array of Files to be removed
or
nFilePos The Position of the file to be removed
Returns
lDeleted 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" )
cFileToCompress Name of a file to Compress, Drive and/or path can be used
or
aFiles An array containing files to compress, Drive and/or path can be used
nLevel Compression level ranging from 0 to 9
bBlock Codeblock to execute while compressing
lOverWrite Toggle to overwrite the file if exists
cPassword Password to encrypt the files
lWithPath Toggle to store the path or not
lWithDrive Toggle to store the Drive letter and path or not
pFileProgress Codeblock for File Progress
Returns
lCompress.T. if file was create, otherwise .F.
Description
This function creates a zip file named cFile. 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 aFiles will be compressed.
If nLevel is used, it determines the compression type where 0 means no compression and 9 means best compression.
If bBlock is used, every time the file is opened to compress it will evaluate bBlock. Parameters of bBlock are cFile and nPos.
If lOverWrite is used, it toggles to overwrite or not the existing file. Default is to overwrite the file, otherwise if lOverWrite is false the new files are added to the cFile.
If cPassword is used, all files that are added to the archive are encrypted with the password.
If lWithPath is used, it tells the path should also be stored with the file name. Default is false.
If lWithDrive is used, it tells that the Drive and path should also be stored with the file name. Default is false.
If pFileProgress is used, a codeblock is evaluated, showing the total of that file has being processed. The codeblock must be defined as: {| nPos, nTotal | GaugeUpdate( aGauge1, nPos / nTotal ) }
Examples
LOCAL aFiles, nLen, aGauge
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 )
hb_ZipFile( "test33.zip", aFiles, 9,,, "hello" )
cFileToCompress Name of a file to Compress, Drive and/or path can be used
or
aFiles An array containing files to compress, Drive and/or path can be used
nLevel Compression level ranging from 0 to 9
bBlock Codeblock to execute while compressing
lOverWrite Toggle to overwrite the file if exists
cPassword Password to encrypt the files
lWithPath Toggle to store the path or not
lWithDrive Toggle to store the Drive letter and path or not
pFileProgress Codeblock for File Progress
Returns
lCompress.T. if file was create, otherwise .F.
Description
This function creates a zip file named cFile. 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 aFiles will be compressed. Also, the use of this function is for creating backup in removable media like an floppy drive/zip drive.
If nLevel is used, it determines the compression type where 0 means no compression and 9 means best compression.
If bBlock is used, every time the file is opened to compress it will evaluate bBlock. Parameters of bBlock are cFile and nPos.
If lOverWrite is used, it toggles to overwrite or not the existing file. Default is to overwrite the file, otherwise if lOverWrite is false the new files are added to the cFile.
If cPassword is used, all files that are added to the archive are encrypted with the password.
If lWithPath is used, it tells that the path should also be stored with the file name. Default is false.
If lWithDrive is used, it tells that the Drive and path should also be stored with the file name. Default is false.
If pFileProgress is used, a codeblock is evaluated, showing the total of that file has being processed. The codeblock must be defined as: {| nPos, nTotal | GaugeUpdate( aGauge1, nPos / nTotal ) }
Before calling this function, set a change-disk codeblock by calling the hb_SetDiskZip().
Examples
LOCAL aFiles, nLen, aGauge
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, {| cFile, nPos | QOut( cFile ) } )
? "File was successfully created"
ENDIF
aFiles := { "test.prg", "test.hbp" }
nLen := Len( aFiles )
hb_ZipFileByPKSpan( "test33.zip", aFiles, 9,,, "hello" )
cFileToCompress Name of a file to Compress, Drive and/or path can be used
or
aFiles An array containing files to compress, Drive and/or path can be used
nLevel Compression level ranging from 0 to 9
bBlock Codeblock to execute while compressing
lOverWrite Toggle to overwrite the file if exists
cPassword Password to encrypt the files
iSize Size of the archive, in bytes. Default is 1457664 bytes
lWithPath Toggle to store the path or not
lWithDrive Toggle to store the Drive letter and path or not
pFileProgress Codeblock for File Progress
Returns
lCompress.T. if file was create, otherwise .F.
Description
This function creates a zip file named cFile. 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 aFiles will be compressed.
If nLevel is used, it determines the compression type where 0 means no compression and 9 means best compression.
If bBlock is used, every time the file is opened to compress it will evaluate bBlock. Parameters of bBlock are cFile and nPos.
If lOverWrite is used, it toggles to overwrite or not the existing file. Default is to overwrite the file, otherwise if lOverWrite is false the new files are added to the cFile.
If lWithPath is used, it tells that the path should also be stored with the file name. Default is false.
If lWithDrive is used, it tells that the Drive and path should also be stored with the file name. Default is false.
If pFileProgress is used, a codeblock is evaluated, showing the total of that file has being processed. The codeblock must be defined as: {| nPos, nTotal | GaugeUpdate( aGauge1, nPos / nTotal ) }
Examples
LOCAL aFiles, nLen, aGauge
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, {| cFile, nPos | QOut( cFile ) }, "hello",, 521421 )
? "File was successfully created"
ENDIF
aFiles := { "test.prg", "test.hbp" }
hb_ZipFileByTDSpan( "test33.zip", aFiles, 9,,, "hello",, 6585452 )