Launcher, based on PickleLauncher
[mupen64plus-pandora.git] / source / mupen64launcher / src / czip.h
1 /**
2  *  @section LICENSE
3  *
4  *  PickleLauncher
5  *  Copyright (C) 2010-2011 Scott Smith
6  *
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.
11  *
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.
16  *
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/>.
19  *
20  *  @section LOCATION
21  */
22
23 #ifndef CZIP_H
24 #define CZIP_H
25
26 #include "cbase.h"
27 #include "unzip/unzip.h"
28
29 using namespace std;
30
31 /** @brief This class handles interfaces to read and extract files from zips.
32  */
33 class CZip : public CBase
34 {
35     public:
36         /** Constructor. */
37         CZip();
38         /** Destructor. */
39         virtual ~CZip();
40
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.
44          */
45         void    ListFiles           ( const string& zipfile, vector<string>& list );
46
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.
52          */
53         void    ExtractFile        ( const string& zipfile, const string& location, const string& filename );
54
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.
59          */
60         void    ExtractFiles        ( const string& zipfile, const string& location );
61
62         /** @brief Deletes files extracted at the designated location
63          */
64         void    DelUnzipFiles       ( void );
65
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.
69          */
70         int8_t  SaveUnzipList       ( const string& location );
71
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.
75          */
76         int8_t  LoadUnzipList       ( const string& location );
77
78     private:
79         /** @brief Display the zip size.
80          * @param n : file size.
81          * @param size_char : number of digits to display.
82          */
83         void    Display64BitsSize   ( ZPOS64_T n, int size_char);
84
85         /** @brief Extracts a file within a zip to the designated location
86          * @param location : location to extract the file to.
87          * @return zip result.
88          */
89         int32_t Extract             ( unzFile uf, const string& location );
90
91         /** @brief Stores the name of an extracted file to a list in memory.
92          * @param filename : filename to record.
93          */
94         void    AddUnzipFile        ( const string& filename );
95
96         vector<string>  UnzipFiles; /**< A list of filenames for files that have been extracted. */
97 };
98
99 #endif // CZIP_H