5 * Copyright (C) 2010-2011 Scott Smith
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include "unzip/unzip.h"
31 /** @brief This class handles interfaces to read and extract files from zips.
33 class CZip : public CBase
41 /** @brief Loads a list of names for files detected in the zip.
42 * @param zipfile : the zip file to read.
43 * @param list : the list of filenames.
45 void ListFiles ( const string& zipfile, vector<string>& list );
47 /** @brief Extracts file within a zip to the designated location.
48 * @param zipfile : the zip file to extract from.
49 * @param location : location to extract the file to.
50 * @param filename : the file to extract.
51 * @param list : the list of filenames.
53 void ExtractFile ( const string& zipfile, const string& location, const string& filename );
55 /** @brief Extracts files within a zip to the designated location.
56 * @param zipfile : the zip file to extract from.
57 * @param location : location to extract the files to.
58 * @param list : the list of filenames.
60 void ExtractFiles ( const string& zipfile, const string& location );
62 /** @brief Deletes files extracted at the designated location
64 void DelUnzipFiles ( void );
66 /** @brief Save a list of extracted files.
67 * @param location : where to save the zip list.
68 * @return 0 if passed 1 if failed.
70 int8_t SaveUnzipList ( const string& location );
72 /** @brief Load a list of extracted files.
73 * @param location : where to load the zip list.
74 * @return 0 if passed 1 if failed.
76 int8_t LoadUnzipList ( const string& location );
79 /** @brief Display the zip size.
80 * @param n : file size.
81 * @param size_char : number of digits to display.
83 void Display64BitsSize ( ZPOS64_T n, int size_char);
85 /** @brief Extracts a file within a zip to the designated location
86 * @param location : location to extract the file to.
89 int32_t Extract ( unzFile uf, const string& location );
91 /** @brief Stores the name of an extracted file to a list in memory.
92 * @param filename : filename to record.
94 void AddUnzipFile ( const string& filename );
96 vector<string> UnzipFiles; /**< A list of filenames for files that have been extracted. */