Compress - Petewg/harbour-core GitHub Wiki
π Home
-
hb_zipOpen(
<cArchive>, [nMode], [@cGlobalComment]
) β hZip
This function attempts to create or open an archive file with namecArchive
, for further archiving operations. Whether it will be created or opened, depends onnMode
value.
IfnMode==HB_ZIP_OPEN_CREATE
(value:0
which is the default), the archive filecArchive
will be created. Warning! if it already exists in the working directory, it will be overwritten!.
IfnMode==HB_ZIP_OPEN_CREATEAFTER
(value:1
) and the archive filecArchive
exists the zips will be created at the end of the file. (useful if the file contains a self extractor code).
IfnMode==HB_ZIP_OPEN_ADDINZIP
(value:2
), thecArchive
will be opened for adding new zips (care to not add files that don't exist).
The<cGlobalComment>
(used in case of opening an existing archive) is the variable of general (global) comment and must be passed by reference, in order to obtain an already existing (stored) comment intocArchive
.
Function returns ahandle
to created/openedcArchive
. In opening cases, ifcArchive
does not exist or is invalid, the function returnsNIL
. -
hb_zipFileCreate(
<hZip>, <cFileName> [, dDate] [, cTime] [, nInternalAttr, nExternalAttr] [, nMethod ] [, nLevel ] [, cPassword, ulFileCRC32] [, cComment]
) β nError
Creates<cFileName>
placeholder into<hZip>
Archive, to be used subsequently by 'hb_zipFileWrite()' for writing the compressed data of that file. The optional[dDate] [cTime] [nInternalAttr, nExternalAttr]
file properties will be applied, if specified.
<nMethod>
is the compression method. Supported methods:HB_ZLIB_METHOD_STORE, HB_ZLIB_METHOD_DEFLATED
. Default:HB_ZLIB_METHOD_DEFLATED
.
<nLevel>
specifies the compression level ranging from 0=none to 9=max. Default isHB_ZLIB_COMPRESSION_DEFAULT
(-1), which, according to Zlib docs, is a compromise between speed and compression (equivalent to level 6).
<cPassword>
is password used to encrypt data and if specified must also given the<ulFileCRC32>
i.e. CRC32 checksum of file; to obtain CRC32 checksum the 'hb_zipFileCRC32()' can be used.
<cComment>
is comment to applied for the compressed and encrypted data. It's meaningful only if[<cPassword>, <ulFileCRC32>
] have used.
The function returnsnError == ZIP_OK (0)
on success, ornError != 0
on error. -
hb_zipFileWrite(
<hZip>, <cData> [, <nLen>]
) β nError
compresses and writes (adds)<cData>
into currently processed file, created by last 'hb_zipFileCreate()' invocation.
<hZip>
is the handler of Archive.<nLen>
is the length of<cData>
to be compressed/written.
returnsnError == ZIP_OK (0)
on success, ornError != 0
on error. -
hb_zipFileClose(
<hZip>
) β nError
closes the current already compressed/stored file (not the Archive!), created by last 'hb_zipFileCreate()' invocation.
<hZip>
is the handler of Archive, into which has been stored the file that is being closed.
returnsnError == ZIP_OK (0)
on success, ornError != 0
on error. -
hb_zipStoreFile(
<hZip>, <cFileName>, [ cZipedName ], [ cPassword, cComment ]
) β nError
directly compresses and stores entire content of<cFileName>
file into opened Archive.
<hZip>
is handle to Archive.
<cFileName>
is the name of file to be compressed/stored.
<cZipedName>
is optional filename by which the compressed content will be (re)named into Archive. If omitted,<cFileName>
will be used.
<cPassword>
is optional password used to encrypt compressed file while<cComment>
is optional comment for that specific file (comment ignored (i.e. not stored) if no password used). returnsnError == ZIP_OK (0)
on success, ornError != 0
on error. -
hb_zipStoreFileHandle(
<hZip>, <hFhandle>, <cZipedName> [, cPassword, cComment]
) β nError
directly compresses and stores into Archive, entire content of an opened file.<hZip>
is handle of Archive.
<hFhandle>
is the handle of an opened (by FOpen()) file that will be compressed / stored.
<cZipedName>
is the filename by which the compressed content will be named into Archive and must explicitly specified, i.e it is not optional as in 'hb_zipStoreFile()'.
<cPassword>
is optional password used to encrypt compressed file while<cComment>
is optional comment for that specific file (comment ignored (i.e. not stored) if no password used).
returnsnError == ZIP_OK (0)
on success, ornError != 0
on error. -
hb_zipClose(
<hZip> [, cGlobalComment ]
) β nError
closes an already created/opened Archive after archiving operations have finished. returnsnError == ZIP_OK (0)
on success, ornError != 0
on error. 'hb_zipErrorStr( nError )' can be used to get a clue about error happened (if any). -
hb_zipDeleteFile(
<cZipFile>, <cFileMask>
) β nError
removes compressed files from an Archive.
<cZipFile>
is the Archive filename from which files will be removed (e.g. "test.zip" ).
<cFileMask>
is the file or group of files that will be removed. Wildcards are supported (e.g. "*.prg").
returnsnError == ZIP_OK (0)
on success, ornError != 0
on error. 'hb_zipErrorStr( nError )' can be used to get clue about error happened (if any). -
hb_zipErrorStr(
<nError>
) β cErrorDescription
returns a descriptive abbreviation ofnError
, that is somehow useful to get a clue about error happened during zip operations. -
hb_zipFileCRC32(
<cFileName>
) β CRC32 | 0
calculates and returnsCRC32
checksum for<cFileName>
or0
on error. can be used in 'hb_zipFileCreate()' to calculate, on the fly, checksum of file being compressed. -
hb_unzipClose(
hUnzip
) β nError -
hb_unzipErrorStr(
<nError>
) β cErrorDescription
returns a descriptive abbreviation ofnError
, that is somehow useful to get a clue about error happened during unzip operations. -
hb_unzipExtractCurrentFile(
hUnzip, [ cFileName ], [ cPassword ]
) β nError -
hb_unzipExtractCurrentFileToHandle(
hZip, fhnd, [ cPassword ]
) β nError -
hb_unzipFileClose(
hUnzip
) β nError -
hb_unzipFileFirst(
hUnzip
) β nError -
hb_unzipFileGoto(
hUnzip, nPosition
) β nError -
hb_unzipFileInfo(
hUnzip, @cZipName, @tDateTime, @cTime, @nInternalAttr, @nExternalAttr, @nMethod, @nSize, @nCompressedSize, @lCrypted, @cComment
) β nError -
hb_unzipFileNext(
hUnzip
) β nError -
hb_unzipFileOpen(
hUnzip, [ cPassword ]
) β nError -
hb_unzipFilePos(
hUnzip
) β nPosition -
hb_unzipFileRead(
hUnzip, @cBuf [, nLen ]
) β nRead -
hb_unzipGlobalInfo(
hUnzip, @nEntries, @cGlobalComment
) β nError -
hb_unzipOpen(
cFileName
) β hUnzip | NIL
Attempts to opencFileName
for unzip operations. Returns handler ofcFileName
on success or NIL on failure.
π Home
-
hb_gzClearErr(
<pGZipStream>
) β NIL -
hb_gzClose(
<pGZipStream>
) β nResult -
hb_gzCompress(
<cData>, [<nDstBufLen>|<@cBuffer>], [<@nResult>], [<nLevel>]
) β cCompressedData|NIL
compresscData
. returns compressed data or NIL on Error. -
hb_gzCompressBound(
<cData>|<nDataLen>
) β nMaxCompressLen -
hb_gzDirect(
pGZipStream
) β lResult -
hb_gzDOpen(
<hFile>, <cMode>
) β pGZipStream
returns pointer to<hFile>
or NIL on Error. -
hb_gzEof(
<pGZipStream>
) β lResult -
hb_gzError(
<pGZipStream>, [<@nError>]
) β cError -
hb_gzFlush(
<pGZipStream>, [<nFlush>]
) β nResult -
hb_gzGetC(
<pGZipStream>
) β nByte -
hb_gzGetS(
<pGZipStream>, <nMaxBytes>
) β cLine or NIL on error -
hb_gzOpen(
<cFile>, <cMode>
) β pGZipStream or NIL on Error -
hb_gzPutC(
<pGZipStream>, <nByte>
) β nResult -
hb_gzPutS(
<pGZipStream>, <cData>
) β nResult -
hb_gzRead(
<pGZipStream>, <@cData>, [<nLen>]
) β nResult -
hb_gzRewind(
<pGZipStream>
) β nResult -
hb_gzSeek(
<pGZipStream>, <nOffset>, [<nWhence>]
) β nOffset -
hb_gzSetParams(
<pGZipStream>, <nLevel>, <nStrategy>
) β nResult -
hb_gzTell(
<pGZipStream>
) β nResult -
hb_gzUnGetC(
<nByte>, <pGZipStream>
) β nByte -
hb_gzWrite(
<pGZipStream>, <cData>, [<nLen>]
) β nResult
-
hb_ZLibVersion(
[<nType>]
) β <ZlibVersion -
hb_ZUncompress(
<cCompressedData>, [<nDstBufLen>|<@cBuffer>], [<@nResult>]
) β cUnCompressedData
returns uncompressed data or NIL on error. -
hb_ZUncompressLen(
<cCompressedData>, [<@nResult>]
) β nLen
returns the length of uncompressed data or-1
on error. -
hb_ZCompress(
<cData>, [<nDstBufLen>|<@cBuffer>], [<@nResult>], [<nLevel>]
) β cCompressedData returns compressed data or NIL on Error. -
hb_ZCompressBound(
<cData>|<nDataLen>
) β nMaxCompressLen -
hb_ZError(
<nError>
) β cErrorDescription
π Home
-
hb_ZipFile(
<cFile>, <cFileToCompress>|<aFiles>, <nLevel>, <bBlock>, <lOverWrite>, <cPassword>, <lWithPath>, <lWithDrive>, <bFileProgress>
) β lSuccess
creates a zip file and returns .T. on success, .F. on failure.
ARGUMENTS
<cFile>
: name of the zip file to create. If the extension is omitted,.zip
will be assumed.;
<cFileToCompress>
or<aFiles>
: name of a file or array of files to compress (can contain drive and/or path);
<nLevel>
: compression level ranging from0
(less) to9
(max);
<bBlock>
: code block evaluated while compressing. parameters passed to bBlock arecFile
andnPos
;
<lOverWrite>
: toggle to overwrite (.T.) or not (.F.) the file if exists (default: .T.);
<cPassword>
: password to encrypt the files;
<lWithPath>
: toggle to store the path or not (default: .F.);
<lWithDrive>
: toggle to store the Drive letter and path or not (default: .F.);
<bFileProgress>
: code block for each File Progress. parameters passed to block arenPos
andnTotal
e.g.:{|nPos,nTotal| GaugeUpdate( aGauge1, nPos / nTotal ) }
. -
hb_GetFileCount(
<cZipFile>
) β nFiles
return number of files in<cZipFile>
or0
(zero) on error (e.g.: when<cZipFile>
cannot be opened et.c). -
hb_GetFilesInZip(
<cZipFile>, [<lVerbose>]
) β aFiles
return array with filenames in<cZipFile>
. If<lVerbose>
=.T. then each element of array returned is a (sub)array with elements:{ cFileName, nSize, nMethod, nCompSize, nRatio, dDate, cTime, hb_NumToHex( nCRC, 8 ), nInternalAttr /* cAttr */, lCrypted, cComment }
-
hb_SetBuffer(
[<nWriteBuffer>], [<nExtractBuffer>], [<nReadBuffer>]
) β NIL
sets the size of the internal buffers for write/extract/read operation. If the sizes is smaller than the default, the function will automatically use the default values, (65535/16384/32768). This function be called before any of the compression/decompression hbziparc function.
π Home