12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- /****************************************************************************
- Copyright (c) 2010-2012 cocos2d-x.org
- Copyright (c) 2013-2017 Chukong Technologies Inc.
- http://www.cocos2d-x.org
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- ****************************************************************************/
- #ifndef __SUPPORT_ZIPUTILS_H__
- #define __SUPPORT_ZIPUTILS_H__
- /// @cond DO_NOT_SHOW
- #include <string>
- /**
- * @addtogroup base
- * @{
- */
- #ifndef _unz64_H
- typedef struct unz_file_info_s unz_file_info;
- #endif
- /** XXX: pragma pack ???
- * @struct CCZHeader
- */
- struct CCZHeader {
- unsigned char sig[4]; /** Signature. Should be 'CCZ!' 4 bytes. */
- unsigned short compression_type; /** Should be 0. */
- unsigned short version; /** Should be 2 (although version type==1 is also supported). */
- unsigned int reserved; /** Reserved for users. */
- unsigned int len; /** Size of the uncompressed file. */
- };
- enum {
- CCZ_COMPRESSION_ZLIB, /** zlib format. */
- CCZ_COMPRESSION_BZIP2, /** bzip2 format (not supported yet). */
- CCZ_COMPRESSION_GZIP, /** gzip format (not supported yet). */
- CCZ_COMPRESSION_NONE, /** plain (not supported yet). */
- };
- class ZipUtils
- {
- public:
- /**
- * Inflates either zlib or gzip deflated memory. The inflated memory is expected to be freed by the caller.
- *
- * It will allocate 256k for the destination buffer. If it is not enough it will multiply the previous buffer size per 2, until there is enough memory.
- *
- * @return The length of the deflated buffer.
- * @since v0.8.1
- */
- static ssize_t ccInflateMemory(unsigned char *in, ssize_t inLength, unsigned char **out) { return inflateMemory(in, inLength, out); }
- static ssize_t inflateMemory(unsigned char *in, ssize_t inLength, unsigned char **out);
- /**
- * Inflates either zlib or gzip deflated memory. The inflated memory is expected to be freed by the caller.
- *
- * @param outLengthHint It is assumed to be the needed room to allocate the inflated buffer.
- *
- * @return The length of the deflated buffer.
- * @since v1.0.0
- */
- static ssize_t ccInflateMemoryWithHint(unsigned char *in, ssize_t inLength, unsigned char **out, ssize_t outLengthHint) { return inflateMemoryWithHint(in, inLength, out, outLengthHint); }
- static ssize_t inflateMemoryWithHint(unsigned char *in, ssize_t inLength, unsigned char **out, ssize_t outLengthHint);
- private:
- static int inflateMemoryWithHint(unsigned char *in, ssize_t inLength, unsigned char **out, ssize_t *outLength, ssize_t outLengthHint);
- };
- // end group
- /// @}
- /// @endcond
- #endif // __SUPPORT_ZIPUTILS_H__
|