ZFFramework
 
Loading...
Searching...
No Matches
ZFCompress.h File Reference

compress util More...

#include "ZFAlgorithmDef.h"

Go to the source code of this file.

Classes

class  v_ZFCompressLevel
 compress level for ZFCompressOpen More...
 
class  ZFCompressToken
 see ZFCompressOpen More...
 

Typedefs

typedef v_ZFCompressLevel::ZFEnumType ZFCompressLevel
 see v_ZFCompressLevel
 

Functions

zfbool ZFCompressLevelFromStringT (zfauto &ret, const zfchar *src, zfindex srcLen=((zfindex) -1), zfstring *errorHint=zft_zfnull)
 see v_ZFCompressLevel, return enum object if success
 
zfbool ZFCompressLevelToStringT (zfstring &ret, v_ZFCompressLevel *const &value, zfstring *errorHint=zft_zfnull)
 see ZFCompressLevel, return empty string if error
 
zfstring ZFCompressLevelToString (v_ZFCompressLevel *const &value, zfstring *errorHint=zft_zfnull)
 see v_ZFCompressLevel, return empty string if error
 
const zfstringZFTypeId_ZFCompressLevel (void)
 
zfbool ZFCompressLevelFromDataT (_ZFP_PropTypeW_ZFCompressLevel &v, const ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializableData *outErrorPos=zft_zfnull)
 see ZFTYPEID_DECLARE
 
_ZFP_PropTypeW_ZFCompressLevel ZFCompressLevelFromData (const ZFSerializableData &serializableData, zfstring *outErrorHint=zft_zfnull, ZFSerializableData *outErrorPos=zft_zfnull)
 see ZFTYPEID_DECLARE
 
zfbool ZFCompressLevelToDataT (ZFSerializableData &serializableData, _ZFP_PropTypeW_ZFCompressLevel const &v, zfstring *outErrorHint=zft_zfnull)
 see ZFTYPEID_DECLARE
 
ZFSerializableData ZFCompressLevelToData (_ZFP_PropTypeW_ZFCompressLevel const &v, zfstring *outErrorHint=zft_zfnull)
 see ZFTYPEID_DECLARE
 
zfbool ZFCompressLevelFromStringT (_ZFP_PropTypeW_ZFCompressLevel &v, const zfchar *src, zfindex srcLen=((zfindex) -1), zfstring *errorHint=zft_zfnull)
 util method to convert ZFCompressLevel from string
 
_ZFP_PropTypeW_ZFCompressLevel ZFCompressLevelFromString (const zfchar *src, zfindex srcLen=((zfindex) -1), zfstring *errorHint=zft_zfnull)
 util method to convert ZFCompressLevel from string
 
zfbool ZFCompressLevelToStringT (zfstring &s, _ZFP_PropTypeW_ZFCompressLevel const &v, zfstring *errorHint=zft_zfnull)
 util method to convert ZFCompressLevel to string
 
zfstring ZFCompressLevelToString (_ZFP_PropTypeW_ZFCompressLevel const &v, zfstring *errorHint=zft_zfnull)
 util method to convert ZFCompressLevel to string
 
zfautoT< ZFCompressTokenZFCompressOpen (const ZFPathInfo &pathInfo, ZFIOOpenOptionFlags flags, ZFCompressLevel compressLevel=(v_ZFCompressLevel::EnumDefault()))
 open compress file for read or write
 
zfbool ZFCompressFile (const ZFPathInfo &outputCompress, const ZFInput &inputRaw, const zfstring &itemPath=(zfstring::shared("content")), ZFCompressLevel compressLevel=(v_ZFCompressLevel::EnumDefault()))
 see ZFCompressOpen
 
zfbool ZFDecompressFile (const ZFOutput &outputRaw, const ZFPathInfo &inputCompress, const zfstring &itemPath=(zfstring::shared("content")))
 see ZFCompressOpen
 
zfbool ZFCompressDir (const ZFPathInfo &outputCompress, const ZFPathInfo &inputPathInfo, const zfstring &itemPath=(zft_zfnull), ZFIOOpenOptionFlags flags=(v_ZFIOOpenOption::e_Modify), ZFCompressLevel compressLevel=(v_ZFCompressLevel::EnumDefault()))
 see ZFCompressOpen
 
zfbool ZFDecompressDir (const ZFPathInfo &outputPathInfo, const ZFPathInfo &inputCompress)
 see ZFCompressOpen
 

Detailed Description

compress util

Function Documentation

◆ ZFTypeId_ZFCompressLevel()

const zfstring & ZFTypeId_ZFCompressLevel ( void )
inline


◆ ZFCompressOpen()

zfautoT< ZFCompressToken > ZFCompressOpen ( const ZFPathInfo & pathInfo,
ZFIOOpenOptionFlags flags,
ZFCompressLevel compressLevel = (v_ZFCompressLevel::EnumDefault()) )
extern

open compress file for read or write

typical usage:

// read and write file in the compress file
compress->read(ZFOutputForXxx(), "item/path/in/compress_file");
compress->write("item/path/in/compress_file", ZFInputForXxx());
// find files in compress file
if(compress->itemFindFirst(fd, "item/path/in/compress_file")) {
do {
...
} while(compress->itemFindNext(fd));
compress->itemFindClose(fd);
}
// iterate items (files or dirs)
for(zfindex i = 0; i < compress->itemCount(); ++i) {
zfstring itemPath = compress->itemPath(i);
}
// explicitly close
// would be closed automatically when compress object deallocated
compress->close();
zfautoT< ZFCompressToken > ZFCompressOpen(const ZFPathInfo &pathInfo, ZFIOOpenOptionFlags flags, ZFCompressLevel compressLevel=(v_ZFCompressLevel::EnumDefault()))
open compress file for read or write
_ZFT_t_zfindex zfindex
similar to size_t, used for index and size only
Definition ZFCoreTypeDef_CoreType.h:154
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
data used by ZFIO when finding files
Definition ZFIODef_fwd.h:71
@ e_Modify
Modify(1 << 2)
Definition ZFIODef_fwd.h:44
type restrict version of zfauto
Definition zfautoFwd.h:113

◆ ZFCompressDir()

zfbool ZFCompressDir ( const ZFPathInfo & outputCompress,
const ZFPathInfo & inputPathInfo,
const zfstring & itemPath = (zft_zfnull),
ZFIOOpenOptionFlags flags = (v_ZFIOOpenOption::e_Modify),
ZFCompressLevel compressLevel = (v_ZFCompressLevel::EnumDefault()) )
extern

see ZFCompressOpen

example of different conditions:

  • itemPath is empty : inputPathInfo's file name would be used as itemPath in compress file
    some_path/dir_name/ <= inputPathInfo
    some_file
    compress_name.zip <= outputCompress
    dir_name/ <= file name specified by inputPathInfo
    some_file <= children of inputPathInfo
  • itemPath is "." : all children would be added to root of the compress file
    some_path/dir_name/ <= inputPathInfo
    some_file
    compress_name.zip <= outputCompress
    some_file <= children of inputPathInfo would be added to root
  • itemPath is valid path : all children would be added to specified itemPath
    some_path/dir_name/ <= inputPathInfo
    some_file
    compress_name.zip <= outputCompress
    some/item/path/
    some_file <= children of inputPathInfo would be added to specified itemPath