cocos2d-x  3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ZipFile Class Reference

Zip file - reader helper class. More...

#include <ZipUtils.h>

Public Member Functions

 ZipFile (const std::string &zipFile, const std::string &filter=std::string())
 Constructor, open zip file and store file list. More...
 
virtual ~ZipFile ()
bool setFilter (const std::string &filter)
 Regenerate accessible file list based on a new filter string. More...
 
bool fileExists (const std::string &fileName) const
 Check does a file exists or not in zip file. More...
 
unsigned char * getFileData (const std::string &fileName, ssize_t *size)
 Get resource file data from a zip file. More...
 
std::string getFirstFilename ()
std::string getNextFilename ()

Static Public Member Functions

static ZipFilecreateWithBuffer (const void *buffer, unsigned long size)

Detailed Description

Zip file - reader helper class.

It will cache the file list of a particular zip file with positions inside an archive, so it would be much faster to read some particular files or to check their existance.

Since
v2.0.5

Constructor & Destructor Documentation

ZipFile ( const std::string &  zipFile,
const std::string &  filter = std::string() 
)

Constructor, open zip file and store file list.

Parameters
zipFileZip file name
filterThe first part of file names, which should be accessible. For example, "assets/". Other files will be missed.
Since
v2.0.5
virtual ~ZipFile ( )
virtual

Member Function Documentation

static ZipFile* createWithBuffer ( const void *  buffer,
unsigned long  size 
)
static
bool fileExists ( const std::string &  fileName) const

Check does a file exists or not in zip file.

Parameters
fileNameFile to be checked on existance
Returns
true whenever file exists, false otherwise
Since
v2.0.5
unsigned char* getFileData ( const std::string &  fileName,
ssize_t size 
)

Get resource file data from a zip file.

Parameters
fileNameFile name
[out]pSizeIf the file read operation succeeds, it will be the data size, otherwise 0.
Returns
Upon success, a pointer to the data is returned, otherwise nullptr.
Warning
Recall: you are responsible for calling free() on any Non-nullptr pointer returned.
Since
v2.0.5
std::string getFirstFilename ( )
std::string getNextFilename ( )
bool setFilter ( const std::string &  filter)

Regenerate accessible file list based on a new filter string.

Parameters
filterNew filter string (first part of files names)
Returns
true whenever zip file is open successfully and it is possible to locate at least the first file, false otherwise
Since
v2.0.5

The documentation for this class was generated from the following file: