Privacy
An open-source, flexible 3D physical simulation framework
zipit.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011, 2012, DFKI GmbH Robotics Innovation Center
3  *
4  * This file is part of the MARS simulation framework.
5  *
6  * MARS is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation, either version 3
9  * of the License, or (at your option) any later version.
10  *
11  * MARS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with MARS. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef ZIPIT_H_INCLUDED
22 #define ZIPIT_H_INCLUDED
23 
24 
25 #include <string>
26 #include <fstream>
27 #include <vector>
28 
29 #include <minizip/unzip.h>
30 #include <minizip/zip.h>
31 
32 
44 namespace mars {
45  namespace smurf {
46 
47  enum ZipitError {
64  };
65 
66  class Zipit
67  {
68  public:
76  Zipit(const std::string &zipFileName);
77  ~Zipit();
78 
79 
80  ZipitError unzipAll(const std::string &zipFilename,
81  const std::string &directory);
82  ZipitError zipDirectory(const std::string &directory,
83  const std::string &zipFile,
84  bool overwrite);
91  int addToZip(const std::string &fileNameToZip ,
92  const std::string &sourceFileNameToZip);
93  int addToZip(const std::vector<std::string> &listOfFiles,
94  const std::vector<std::string> &sourceListOfFiles);
101  int getFromZip(const std::string &inZipFileName,
102  const std::string &whereToStore);
103  int getFromZip(const std::vector<std::string> &allFileNamesToRead,
104  const std::vector<std::string> &v_whereToStore);
105 
106  int unpackWholeZipTo(const std::string &whereToStore);
107  int closeZipHandle();
108  int closeUnZipHandle();
109 
110  private:
111 
120  int openZipHandle();
121 
122  int openUnZipHandle();
123 
124 
125 
130  void zipError(ZipitError errorNumber);
131 
135  zipFile zipHandle;
136  unzFile unZipHandle;
137  std::string zipFileName;
138  };
139 
140  } // end of namespace smurf
141 } // end of namespace mars
142 
143 #endif
unzFile unZipHandle
Definition: zipit.h:136
int closeZipHandle()
Definition: zipit.cpp:65
int closeUnZipHandle()
Definition: zipit.cpp:85
int addToZip(const std::string &fileNameToZip, const std::string &sourceFileNameToZip)
int addToZip(string fileNameToZip, bool zipWithFolders); and int addToZip(string fileNameToZip, bool zipWithFolders, vector<string> listOfFiles); both adding file(s) to a zipfile.
ZipitError unzipAll(const std::string &zipFilename, const std::string &directory)
Definition: zipit.cpp:348
int openZipHandle()
int openZipHandle(); int closeZipHandle(); int openUnZipHandle(); int closeUnZipHandle(); ...
Definition: zipit.cpp:56
Zipit(const std::string &zipFileName)
int zipit(string zipFileName); the constructor just initialises some internal values, i.e.
std::string zipFileName
Definition: zipit.h:137
ZipitError
Definition: zipit.h:47
Copyright 2012, DFKI GmbH Robotics Innovation Center.
int openUnZipHandle()
Definition: zipit.cpp:76
ZipitError zipDirectory(const std::string &directory, const std::string &zipFile, bool overwrite)
Definition: zipit.cpp:37
int getFromZip(const std::string &inZipFileName, const std::string &whereToStore)
an important fearture to add: an ability to spezify an folder, where the files should be stored ...
zipFile zipHandle
just a few internal variables.
Definition: zipit.h:135
void zipError(ZipitError errorNumber)
until now, this function does nothing, but in future it should be just to generate uniformed errorMes...
Definition: zipit.cpp:256
int unpackWholeZipTo(const std::string &whereToStore)