Compress - Petewg/harbour-core GitHub Wiki

πŸ”™ Home

hbmzip library (minizip)

  • hb_zipOpen(<cArchive>, [nMode], [@cGlobalComment]) ➜ hZip
    This function attempts to create or open an archive file with name cArchive, for further archiving operations. Whether it will be created or opened, depends on nMode value.
    If nMode==HB_ZIP_OPEN_CREATE (value:0 which is the default), the archive file cArchive will be created. Warning! if it already exists in the working directory, it will be overwritten!.
    If nMode==HB_ZIP_OPEN_CREATEAFTER (value:1) and the archive file cArchive exists the zips will be created at the end of the file. (useful if the file contains a self extractor code).
    If nMode==HB_ZIP_OPEN_ADDINZIP (value:2), the cArchive 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 into cArchive.
    Function returns a handle to created/opened cArchive. In opening cases, if cArchive does not exist or is invalid, the function returns NIL.

  • 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 is HB_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 returns nError == ZIP_OK (0) on success, or nError != 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.
    returns nError == ZIP_OK (0) on success, or nError != 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.
    returns nError == ZIP_OK (0) on success, or nError != 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). returns nError == ZIP_OK (0) on success, or nError != 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).
    returns nError == ZIP_OK (0) on success, or nError != 0 on error.

  • hb_zipClose(<hZip> [, cGlobalComment ]) ➜ nError
    closes an already created/opened Archive after archiving operations have finished. returns nError == ZIP_OK (0) on success, or nError != 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").
    returns nError == ZIP_OK (0) on success, or nError != 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 of nError, that is somehow useful to get a clue about error happened during zip operations.

  • hb_zipFileCRC32(<cFileName>) ➜ CRC32 | 0
    calculates and returns CRC32 checksum for <cFileName> or 0 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 of nError, 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 open cFileName for unzip operations. Returns handler of cFileName on success or NIL on failure.

πŸ”™ Home


Harbour-core compress (zlib etc) functions

  • hb_gzClearErr(<pGZipStream>) ➜ NIL

  • hb_gzClose(<pGZipStream>) ➜ nResult

  • hb_gzCompress(<cData>, [<nDstBufLen>|<@cBuffer>], [<@nResult>], [<nLevel>] ) ➜ cCompressedData|NIL
    compress cData. 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


hbZiparc library

  • 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 from 0 (less) to 9 (max);
    <bBlock> : code block evaluated while compressing. parameters passed to bBlock are cFile and nPos;
    <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 are nPos and nTotal e.g.: {|nPos,nTotal| GaugeUpdate( aGauge1, nPos / nTotal ) }.

  • hb_GetFileCount(<cZipFile>) ➜ nFiles
    return number of files in <cZipFile> or 0 (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

⚠️ **GitHub.com Fallback** ⚠️