Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-13 10:29:00

0001 
0002 #ifndef LIBZIPPP_H
0003 #define LIBZIPPP_H
0004 
0005 /*
0006   libzippp.h -- exported declarations.
0007   Copyright (C) 2013 Cédric Tabin
0008 
0009   This file is part of libzippp, a library that wraps libzip for manipulating easily
0010   ZIP files in C++.
0011   The author can be contacted on http://www.astorm.ch/blog/index.php?contact
0012 
0013   Redistribution and use in source and binary forms, with or without
0014   modification, are permitted provided that the following conditions
0015   are met:
0016   1. Redistributions of source code must retain the above copyright
0017      notice, this list of conditions and the following disclaimer.
0018   2. Redistributions in binary form must reproduce the above copyright
0019      notice, this list of conditions and the following disclaimer in
0020      the documentation and/or other materials provided with the
0021      distribution.
0022   3. The names of the authors may not be used to endorse or promote
0023      products derived from this software without specific prior
0024      written permission.
0025  
0026   THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
0027   OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
0028   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0029   ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
0030   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0031   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
0032   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0033   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
0034   IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
0035   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
0036   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0037 */
0038 
0039 #include <cstdio>
0040 #include <string>
0041 #include <vector>
0042 
0043 //defined in libzip
0044 struct zip;
0045 
0046 #define DIRECTORY_SEPARATOR '/'
0047 #define IS_DIRECTORY(str) ((str).length()>0 && (str)[(str).length()-1]==DIRECTORY_SEPARATOR)
0048 #define DEFAULT_CHUNK_SIZE 524288
0049 
0050 //libzip documentation
0051 //- http://www.nih.at/libzip/libzip.html
0052 //- http://slash.developpez.com/tutoriels/c/utilisation-libzip/
0053 
0054 //standard unsigned int
0055 typedef unsigned int uint;
0056 
0057 #ifdef WIN32
0058         typedef long long libzippp_int64;
0059         typedef unsigned long long libzippp_uint64;
0060         typedef unsigned short libzippp_uint16;
0061         
0062         //special declarations for windows to use libzippp from a DLL
0063         #define SHARED_LIBRARY_EXPORT __declspec(dllexport)
0064         #define SHARED_LIBRARY_IMPORT __declspec(dllimport)
0065 #else
0066         //standard ISO c++ does not support long long
0067         typedef long int libzippp_int64;
0068         typedef unsigned long int libzippp_uint64;
0069         typedef unsigned short libzippp_uint16;
0070         
0071         #define SHARED_LIBRARY_EXPORT
0072         #define SHARED_LIBRARY_IMPORT
0073 #endif
0074 
0075 #ifdef LIBZIPPP_EXPORTS
0076         #define LIBZIPPP_INTERNAL
0077         #define LIBZIPPP_API SHARED_LIBRARY_EXPORT
0078 #else
0079         #define LIBZIPPP_API SHARED_LIBRARY_IMPORT
0080 #endif
0081 
0082 // special return code for libzippp
0083 #define LIBZIPPP_OK 0
0084 #define LIBZIPPP_ERROR_NOT_OPEN -1
0085 #define LIBZIPPP_ERROR_NOT_ALLOWED -2
0086 #define LIBZIPPP_ERROR_INVALID_ENTRY -3
0087 #define LIBZIPPP_ERROR_INVALID_PARAMETER -4
0088 #define LIBZIPPP_ERROR_MEMORY_ALLOCATION -16
0089 #define LIBZIPPP_ERROR_FOPEN_FAILURE -25
0090 #define LIBZIPPP_ERROR_FREAD_FAILURE -26
0091 #define LIBZIPPP_ERROR_OWRITE_FAILURE -35
0092 #define LIBZIPPP_ERROR_OWRITE_INDEX_FAILURE -36
0093 #define LIBZIPPP_ERROR_UNKNOWN -99
0094 
0095 namespace libzippp {
0096     class ZipEntry;
0097     
0098     /**
0099      * Represents a ZIP archive. This class provides useful methods to handle an archive
0100      * content. It is simply a wrapper around libzip.
0101      */
0102     class LIBZIPPP_API ZipArchive {
0103     public:
0104         
0105         /**
0106          * Defines how the zip file must be open.
0107          * NOT_OPEN is a special mode where the file is not open.
0108          * READ_ONLY is the basic mode to only read the archive.
0109          * WRITE will append to an existing archive or create a new one if it does not exist.
0110          * NEW will create a new archive or erase all the data if a previous one exists.
0111          */
0112         enum OpenMode {
0113             NOT_OPEN,
0114             READ_ONLY,
0115             WRITE,
0116             NEW
0117         };
0118         
0119         /**
0120          * Defines how the reading of the data should be made in the archive.
0121          * ORIGINAL will read the data of the original archive file, without any change.
0122          * CURRENT will read the current content of the archive.
0123          */
0124         enum State {
0125             ORIGINAL,
0126             CURRENT
0127         };
0128         
0129         /**
0130          * Creates a new ZipArchive with the given path. If the password is defined, it
0131          * will be used to read encrypted archive. It won't affect the files added
0132          * to the archive.
0133          * 
0134          * http://nih.at/listarchive/libzip-discuss/msg00219.html
0135          */
0136         explicit ZipArchive(const std::string& zipPath, const std::string& password="");
0137         virtual ~ZipArchive(void); //commit all the changes if open
0138         
0139         /**
0140          * Return the path of the ZipArchive.
0141          */
0142         std::string getPath(void) const { return path; }
0143         
0144         /**
0145          * Open the ZipArchive with the given mode. This method will return true if the operation
0146          * is successful, false otherwise. If the OpenMode is NOT_OPEN an invalid_argument
0147          * will be thrown. If the archive is already open, this method returns true only if the
0148          * mode is the same.
0149          */
0150         bool open(OpenMode mode=READ_ONLY, bool checkConsistency=false);
0151         
0152         /**
0153          * Closes the ZipArchive and releases all the resources held by it. If the ZipArchive was
0154          * not open previously, this method does nothing. If the archive was open in modification
0155          * and some were done, they will be committed.
0156          * This method returns LIBZIPPP_OK if the archive was successfully closed, otherwise it 
0157          * returns the value returned by the zip_close() function.
0158          */
0159         int close(void);
0160         
0161         /**
0162          * Closes the ZipArchive and releases all the resources held by it. If the ZipArchive was
0163          * not open previously, this method does nothing. If the archive was open in modification
0164          * and some were done, they will be rollbacked.
0165          */
0166         void discard(void);
0167         
0168         /**
0169          * Deletes the file denoted by the path. If the ZipArchive is open, all the changes will
0170          * be discarded and the file removed.
0171          */
0172         bool unlink(void);
0173         //bool delete(void) { return unlink(); } //delete is a reserved keyword
0174         
0175         /**
0176          * Returns true if the ZipArchive is currently open.
0177          */
0178         inline bool isOpen(void) const { return zipHandle!=NULL; }
0179         
0180         /**
0181          * Returns true if the ZipArchive is open and mutable.
0182          */
0183         inline bool isMutable(void) const { return isOpen() && mode!=NOT_OPEN && mode!=READ_ONLY; }
0184         
0185         /**
0186          * Returns true if the ZipArchive is encrypted. This method returns true only if
0187          * a password has been set in the constructor.
0188          */
0189         inline bool isEncrypted(void) const { return !password.empty(); }
0190         
0191         /**
0192          * Defines the comment of the archive. In order to set the comment, the archive
0193          * must have been open in WRITE or NEW mode. If the archive is not open, the getComment
0194          * method will return an empty string.
0195          */
0196         std::string getComment(State state=CURRENT) const;
0197         bool setComment(const std::string& comment) const;
0198         
0199         /**
0200          * Removes the comment of the archive, if any. The archive must have been open
0201          * in WRITE or NEW mode.
0202          */
0203         inline bool removeComment(void) const { return setComment(std::string()); }
0204         
0205         /**
0206          * Returns the number of entries in this zip file (folders are included).
0207          * The zip file must be open otherwise LIBZIPPP_ERROR_NOT_OPEN will be returned. 
0208          * If the state is ORIGINAL, then the number entries of the original archive are returned.
0209          * Any change will not be considered.
0210          * Note also that the deleted entries does not affect the result of this method
0211          * with the CURRENT state. For instance, if there are 3 entries and you delete one,
0212          * this method will still return 3. However, if you add one entry, it will return
0213          * 4 with the state CURRENT and 3 with the state ORIGINAL.
0214          * If you wanna know the "real" entries effectively in the archive, you might use
0215          * the getEntries method.
0216          */
0217         libzippp_int64 getNbEntries(State state=CURRENT) const;
0218         inline libzippp_int64 getEntriesCount(State state=CURRENT) const { return getNbEntries(state); }
0219         //libzippp_int64 size(State state=CURRENT) const { return getNbEntries(state); } //not clear enough => could be the size of the file instead...
0220 
0221         /**
0222          * Returns all the entries of the ZipArchive. If the state is ORIGINAL, then
0223          * returns the entries in the original archive, any change will not be considered.
0224          * The zip file must be open otherwise an empty vector will be returned.
0225          */
0226         std::vector<ZipEntry> getEntries(State state=CURRENT) const;
0227         
0228         /**
0229          * Return true if an entry with the specified name exists. If no such entry exists,
0230          * then false will be returned. If a directory is searched, the name must end with a '/' !
0231          * The zip file must be open otherwise false will be returned.
0232          */
0233         bool hasEntry(const std::string& name, bool excludeDirectories=false, bool caseSensitive=true, State state=CURRENT) const;
0234         
0235         /**
0236          * Return the ZipEntry for the specified entry name. If no such entry exists,
0237          * then a null-ZiPEntry will be returned. If a directory is searched, the name
0238          * must end with a '/' !
0239          * The zip file must be open otherwise a null-ZipEntry will be returned.
0240          */
0241         ZipEntry getEntry(const std::string& name, bool excludeDirectories=false, bool caseSensitive=true, State state=CURRENT) const;
0242         
0243         /**
0244          * Return the ZipEntry for the specified index. If the index is out of range,
0245          * then a null-ZipEntry will be returned.
0246          * The zip file must be open otherwise a null-ZipEntry will be returned.
0247          */
0248         ZipEntry getEntry(libzippp_int64 index, State state=CURRENT) const;
0249         
0250         /**
0251          * Defines the comment of the entry. If the ZipArchive is not open or the
0252          * entry is not linked to this archive, then an empty string or false will 
0253          * be returned.
0254          */
0255         std::string getEntryComment(const ZipEntry& entry, State state=CURRENT) const;
0256         bool setEntryComment(const ZipEntry& entry, const std::string& comment) const;
0257         
0258         /**
0259          * Defines the compression method of an entry. If the ZipArchive is not open
0260          * or the entry is not linked to this archive, false will be returned.
0261          **/
0262         bool isEntryCompressionEnabled(const ZipEntry& entry) const;
0263         bool setEntryCompressionEnabled(const ZipEntry& entry, bool value) const;
0264         
0265         /**
0266          * Read the specified ZipEntry of the ZipArchive and returns its content within
0267          * a char array. If there is an error while reading the entry, then null will be returned.
0268          * The data must be deleted by the developer once not used anymore. If the asText
0269          * is set to true, then the returned void* will be ended by a \0 (hence the size of
0270          * the returned array will be zipEntry.getSize()+1 or size+1 if the latter is specified).
0271          * The zip file must be open otherwise null will be returned. If the ZipEntry was not
0272          * created by this ZipArchive, null will be returned.
0273          */
0274         void* readEntry(const ZipEntry& zipEntry, bool asText=false, State state=CURRENT, libzippp_uint64 size=0) const;
0275         
0276         /**
0277          * Read the specified ZipEntry of the ZipArchive and returns its content within
0278          * a char array. If there is an error while reading the entry, then null will be returned.
0279          * The data must be deleted by the developer once not used anymore. If the asText
0280          * is set to true, then the returned void* will be ended by a \0 (hence the size of
0281          * the returned array will be zipEntry.getSize()+1 or size+1 if the latter is specified).
0282          * The zip file must be open otherwise null will be returned. If the ZipEntry was not
0283          * created by this ZipArchive, null will be returned. If the zipEntry does not exist,
0284          * this method returns NULL:
0285          */
0286         void* readEntry(const std::string& zipEntry, bool asText=false, State state=CURRENT, libzippp_uint64 size=0) const;
0287         
0288         /**
0289          * Read the specified ZipEntry of the ZipArchive and inserts its content in the provided reference to an already
0290          * opened std::ofstream, gradually, with chunks of size "chunksize" to reduce memory usage when dealing with big files.
0291          * The method returns LIBZIPPP_OK if the extraction has succeeded with no problems, LIBZIPPP_ERROR_INVALID_PARAMETER if the 
0292          * ofstream is not opened, LIBZIPPP_ERROR_NOT_OPEN if the archive is not opened, LIBZIPPP_ERROR_INVALID_ENTRY if the zipEntry 
0293          * doesn't belong to the archive, LIBZIPPP_ERROR_FOPEN_FAILURE if zip_fopen_index() has failed, LIBZIPPP_ERROR_MEMORY_ALLOCATION if 
0294          * a memory allocation has failed, LIBZIPPP_ERROR_FREAD_FAILURE if zip_fread() didn't succeed to read data, 
0295          * LIBZIPPP_ERROR_OWRITE_INDEX_FAILURE if the last ofstream operation has failed, LIBZIPPP_ERROR_OWRITE_FAILURE if fread() didn't 
0296          * return the exact amount of requested bytes and -9 if the amount of extracted bytes didn't match the size of the file (unknown error).
0297          * If the provided chunk size is zero, it will be defaulted to DEFAULT_CHUNK_SIZE (512KB).
0298          * The method doesn't close the ofstream after the extraction.
0299          */
0300         int readEntry(const ZipEntry& zipEntry, std::ofstream& ofOutput, State state=CURRENT, libzippp_uint64 chunksize=DEFAULT_CHUNK_SIZE) const;
0301 
0302         /**
0303          * Deletes the specified entry from the zip file. If the entry is a folder, all its
0304          * subentries will be removed. This method returns the number of entries removed.
0305          * If the open mode does not allow a deletion, this method will return LIBZIPPP_ERROR_NOT_ALLOWED. 
0306          * If the ZipArchive is not open, LIBZIPPP_ERROR_NOT_OPEN will be returned. If the entry is not handled 
0307          * by this ZipArchive or is a null-ZipEntry, then LIBZIPPP_ERROR_INVALID_ENTRY will be returned.
0308          * If an error occurs during deletion, this method will return LIBZIPPP_ERROR_UNKNOWN.
0309          * Note that this method does not affect the result returned by getNbEntries !
0310          */
0311         int deleteEntry(const ZipEntry& entry) const;
0312         
0313         /**
0314          * Deletes the specified entry from the zip file. If the entry is a folder, all its
0315          * subentries will be removed. This method returns the number of entries removed.
0316          * If the open mode does not allow a deletion, this method will return LIBZIPPP_ERROR_NOT_ALLOWED. 
0317          * If the ZipArchive is not open, LIBZIPPP_ERROR_NOT_OPEN will be returned. If the entry is not handled 
0318          * by this ZipArchive or is a null-ZipEntry, then LIBZIPPP_ERROR_INVALID_ENTRY will be returned.
0319          * If an error occurs during deletion, this method will return LIBZIPPP_ERROR_UNKNOWN.
0320          * If the entry does not exist, this method returns LIBZIPPP_ERROR_INVALID_PARAMETER.
0321          * Note that this method does not affect the result returned by getNbEntries !
0322          */
0323         int deleteEntry(const std::string& entry) const;
0324         
0325         /**
0326          * Renames the entry with the specified newName. The method returns the number of entries
0327          * that have been renamed, LIBZIPPP_ERROR_INVALID_PARAMETER if the new name is invalid, 
0328          * LIBZIPPP_ERROR_NOT_ALLOWED if the mode doesn't allow modification or LIBZIPPP_ERROR_UNKNOWN if an error 
0329          * occurred.  If the entry is a directory, a '/' will automatically be appended at the end of newName if the 
0330          * latter hasn't it already. All the files in the folder will be moved.
0331          * If the ZipArchive is not open or the entry was not edited by this ZipArchive or is a null-ZipEntry,
0332          * then LIBZIPPP_ERROR_INVALID_ENTRY will be returned.
0333          */
0334         int renameEntry(const ZipEntry& entry, const std::string& newName) const;
0335         
0336         /**
0337          * RRenames the entry with the specified newName. The method returns the number of entries
0338          * that have been renamed, LIBZIPPP_ERROR_INVALID_PARAMETER if the new name is invalid, 
0339          * LIBZIPPP_ERROR_NOT_ALLOWED if the mode doesn't allow modification or LIBZIPPP_ERROR_UNKNOWN if an error 
0340          * occurred.  If the entry is a directory, a '/' will automatically be appended at the end of newName if the 
0341          * latter hasn't it already. All the files in the folder will be moved.
0342          * If the ZipArchive is not open or the entry was not edited by this ZipArchive or is a null-ZipEntry,
0343          * then LIBZIPPP_ERROR_INVALID_ENTRY will be returned. If the entry does not exist, this method returns LIBZIPPP_ERROR_INVALID_PARAMETER.
0344          */
0345         int renameEntry(const std::string& entry, const std::string& newName) const;
0346         
0347         /**
0348          * Add the specified file in the archive with the given entry. If the entry already exists,
0349          * it will be replaced. This method returns true if the file has been added successfully. 
0350          * If the entryName specifies folders that doesn't exist in the archive, they will be automatically created.
0351          * If the entryName denotes a directory, this method returns false.
0352          * The zip file must be open otherwise false will be returned.
0353          */
0354         bool addFile(const std::string& entryName, const std::string& file) const;
0355         
0356         /**
0357          * Add the given data to the specified entry name in the archive. If the entry already exists,
0358          * its content will be erased. 
0359          * If the entryName specifies folders that doesn't exist in the archive, they will be automatically created.
0360          * If the entryName denotes a directory, this method returns false.
0361          * If the zip file is not open, this method returns false.
0362          */
0363         bool addData(const std::string& entryName, const void* data, libzippp_uint64 length, bool freeData=false) const;
0364         
0365         /**
0366          * Add the specified entry to the ZipArchive. All the needed hierarchy will be created.
0367          * The entryName must be a directory (end with '/').
0368          * If the ZipArchive is not open or the entryName is not a directory, this method will
0369          * returns false. If the entry already exists, this method returns true.
0370          * This method will only add the specified entry. The 'real' directory may exist or not.
0371          * If the directory exists, the files in it won't be added to the archive.
0372          */
0373         bool addEntry(const std::string& entryName) const;
0374         
0375         /**
0376          * Returns the mode in which the file has been open.
0377          * If the archive is not open, then NOT_OPEN will be returned.
0378          */
0379         inline OpenMode getMode(void) const { return mode; }
0380 
0381     private:
0382         std::string path;
0383         zip* zipHandle;
0384         OpenMode mode;
0385         std::string password;
0386         
0387         //generic method to create ZipEntry
0388         ZipEntry createEntry(struct zip_stat* stat) const;
0389         
0390         //prevent copy across functions
0391         ZipArchive(const ZipArchive& zf);
0392         ZipArchive& operator=(const ZipArchive&);
0393     };
0394     
0395     /**
0396      * Represents an entry in a zip file.
0397      * This class is meant to be used by the ZipArchive class.
0398      */
0399     class LIBZIPPP_API ZipEntry {
0400     friend class ZipArchive;
0401     public:
0402         /**
0403          * Creates a new null-ZipEntry. Only a ZipArchive will create a valid ZipEntry
0404          * usable to read and modify an archive.
0405          */
0406         explicit ZipEntry(void) : zipFile(NULL), index(0), time(0), compressionMethod(-1), encryptionMethod(-1), size(0), sizeComp(0), crc(0)  {}
0407         virtual ~ZipEntry(void) {}
0408         
0409         /**
0410          * Returns the name of the entry.
0411          */
0412         inline std::string getName(void) const { return name; }
0413         
0414         /**
0415          * Returns the index of the file in the zip.
0416          */
0417         inline libzippp_uint64 getIndex(void) const { return index; }
0418         
0419         /**
0420          * Returns the timestamp of the entry.
0421          */
0422         inline time_t getDate(void) const { return time; }
0423         
0424         /**
0425          * Returns the compression method.
0426          */
0427         inline libzippp_uint16 getCompressionMethod(void) const { return compressionMethod; }
0428         
0429         /**
0430          * Returns the encryption method.
0431          */
0432         inline libzippp_uint16 getEncryptionMethod(void) const { return encryptionMethod; }
0433         
0434         /**
0435          * Returns the size of the file (not deflated).
0436          */
0437         inline libzippp_uint64 getSize(void) const { return size; }
0438         
0439         /**
0440          * Returns the size of the inflated file.
0441          */
0442         inline libzippp_uint64 getInflatedSize(void) const { return sizeComp; }
0443         
0444         /**
0445          * Returns the CRC of the file.
0446          */
0447         inline int getCRC(void) const { return crc; }
0448         
0449         /**
0450          * Returns true if the entry is a directory.
0451          */
0452         inline bool isDirectory(void) const { return IS_DIRECTORY(name); }
0453         
0454         /**
0455          * Returns true if the entry is a file.
0456          */
0457         inline bool isFile(void) const { return !isDirectory(); }
0458         
0459         /**
0460          * Returns true if this entry is null (means no more entry is available).
0461          */
0462         inline bool isNull(void) const { return zipFile==NULL; }
0463         
0464         /**
0465          * Defines if the compression is enabled for this entry.
0466          * Those methods are wrappers arount ZipArchive::isEntryCompressionEnabled and
0467          * ZipArchive::setEntryCompressionEnabled.
0468          */
0469         bool isCompressionEnabled(void) const;
0470         bool setCompressionEnabled(bool value) const;
0471         
0472         /**
0473          * Defines the comment of the entry. In order to call either one of those
0474          * methods, the corresponding ZipArchive must be open otherwise an empty string
0475          * or false will be returned. Those methods are wrappers around ZipArchive::getEntryComment
0476          * and ZipArchive::setEntryComment.
0477          */
0478         std::string getComment(void) const;
0479         bool setComment(const std::string& str) const;
0480         
0481         /**
0482          * Read the content of this ZipEntry as text. 
0483          * The returned string will be of size getSize() if the latter is not specified or too big. 
0484          * If the ZipArchive is not open, this method returns an
0485          * empty string. This method is a wrapper around ZipArchive::readEntry(...).
0486          */
0487         std::string readAsText(ZipArchive::State state=ZipArchive::CURRENT, libzippp_uint64 size=0) const;
0488         
0489         /**
0490          * Read the content of this ZipEntry as binary. 
0491          * The returned void* will be of size getSize() if the latter is not specified or too big.
0492          * If the ZipArchive is not open, this method returns NULL. 
0493          * The data must be deleted by the developer once not used anymore.
0494          * This method is a wrapper around ZipArchive::readEntry(...).
0495          */
0496         void* readAsBinary(ZipArchive::State state=ZipArchive::CURRENT, libzippp_uint64 size=0) const;
0497         
0498         /**
0499          * Read the specified ZipEntry of the ZipArchive and inserts its content in the provided reference to an already
0500          * opened std::ofstream, gradually, with chunks of size "chunksize" to reduce memory usage when dealing with big files.
0501          * The method returns LIBZIPPP_OK if the extraction has succeeded with no problems, LIBZIPPP_ERROR_INVALID_PARAMETER if the 
0502          * ofstream is not opened, LIBZIPPP_ERROR_NOT_OPEN if the archive is not opened, LIBZIPPP_ERROR_INVALID_ENTRY if the zipEntry 
0503          * doesn't belong to the archive, LIBZIPPP_ERROR_FOPEN_FAILURE if zip_fopen_index() has failed, LIBZIPPP_ERROR_MEMORY_ALLOCATION if 
0504          * a memory allocation has failed, LIBZIPPP_ERROR_FREAD_FAILURE if zip_fread() didn't succeed to read data, 
0505          * LIBZIPPP_ERROR_OWRITE_INDEX_FAILURE if the last ofstream operation has failed, LIBZIPPP_ERROR_OWRITE_FAILURE if fread() didn't 
0506          * return the exact amount of requested bytes and -9 if the amount of extracted bytes didn't match the size of the file (unknown error).
0507          * If the provided chunk size is zero, it will be defaulted to DEFAULT_CHUNK_SIZE (512KB).
0508          * The method doesn't close the ofstream after the extraction.
0509          */
0510         int readContent(std::ofstream& ofOutput, ZipArchive::State state=ZipArchive::CURRENT, libzippp_uint64 chunksize=DEFAULT_CHUNK_SIZE) const;
0511         
0512     private:
0513         const ZipArchive* zipFile;
0514         std::string name;
0515         libzippp_uint64 index;
0516         time_t time;
0517         libzippp_uint16 compressionMethod;
0518         libzippp_uint16 encryptionMethod;
0519         libzippp_uint64 size;
0520         libzippp_uint64 sizeComp;
0521         int crc;
0522         
0523         ZipEntry(const ZipArchive* zipFile, const std::string& name, libzippp_uint64 index, time_t time, libzippp_uint16 compMethod, libzippp_uint16 encMethod, libzippp_uint64 size, libzippp_uint64 sizeComp, int crc) : 
0524                 zipFile(zipFile), name(name), index(index), time(time), compressionMethod(compMethod), encryptionMethod(encMethod), size(size), sizeComp(sizeComp), crc(crc) {}
0525     };
0526 }
0527 
0528 #endif
0529