libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CRNZip.h
Go to the documentation of this file.
1 /* Copyright 2013-2014 INSA-Lyon, CoReNum
2  *
3  * This file is part of libcrn.
4  *
5  * libcrn is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * libcrn is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libcrn. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * file: CRNZip.h
19  * \author Yann LEYDIER
20  */
21 
22 #ifndef CRNZip_HEADER
23 #define CRNZip_HEADER
24 
25 #include <CRN.h>
26 #ifdef CRN_USING_LIBZIP
27 
28 namespace crn
29 {
30  class StringUTF8;
31  class Path;
32 
40  class Zip
41  {
42  public:
44  static Zip NewFromFile(const Path &fname, bool check_consistency = true);
46  static Zip Create(const Path &fname, bool overwrite, bool check_consistency = true);
47 
48  ~Zip();
49  Zip(const Zip&) = delete;
50  Zip(Zip &&z) noexcept;
51  Zip& operator=(const Zip&) = delete;
52  Zip& operator=(Zip &&z) noexcept;
53 
55  void Save();
57  void SetAutoSave(bool autosave);
58 
60  void AddFile(const StringUTF8 &path, const void *data, size_t len, bool overwrite = true);
62  void AddFile(const StringUTF8 &path, const Path &original_file, bool overwrite = true);
64  void AddDirectory(const StringUTF8 &path);
66  bool Exists(const StringUTF8 &path);
67 
69  StringUTF8 ReadTextFile(const StringUTF8 &path);
70 
71  private:
73  Zip(const Path &fname, bool create, bool overwrite, bool check_consistency);
74 
75  struct Impl;
76  std::unique_ptr<Impl> pimpl;
77  };
78 
80 }
81 
82 #endif// CRN_USING_LIBZIP
83 
84 #endif
85 
#define true
Definition: ConvertUTF.cpp:57
CRN_ALIAS_SMART_PTR(ImageBW)