Cafu Engine
FileSys_ZipArchive_GV.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_FILESYS_FILESYSTEM_ZIPARCHIVE_GV_HPP_INCLUDED
8 #define CAFU_FILESYS_FILESYSTEM_ZIPARCHIVE_GV_HPP_INCLUDED
9 
10 #include "FileSys.hpp"
11 #include "minizip/unzip.h"
12 #include <map>
13 
14 
15 namespace cf
16 {
17  namespace FileSys
18  {
19  /// This class implements file systems that are ZIP archives, employing the unzip library by Gilles Vollant.
20  /// The unzip library is part of the minizip contribution to the zlib, and comes under the same liberal zlib license.
22  {
23  public:
24 
25  /// Constructor.
26  /// @throws FileSystemExceptionT when there is a problem with initializing this file system.
27  FileSystemZipArchiveGVT(const std::string& ArchiveName, const std::string& MountPoint, const std::string& Password="");
28 
29  /// Destructor. Destroys the file system.
31 
32  // Implement all the (pure) virtual methods of the FileSystemT class.
33  InFileI* OpenRead(const std::string& FileName);
34 
35 
36  private:
37 
38  const std::string m_ArchiveName; ///< The name of the zip archive.
39  const std::string m_ArchivePassword; ///< The password for decrypting the contents of the zip archive.
40  void* m_ArchiveHandle; ///< The file handle to the opened zip archive itself, for use with all the unzip functions.
41  const std::string m_MountPoint; ///< The mount point of the archive contents.
42  const std::string::size_type m_MountPointLen; ///< The length of the m_MountPoint string.
43  std::map<std::string, unz_file_pos> m_NameToFilePos; ///< Maps a file name to the related position/index in the zip archive.
44  };
45  }
46 }
47 
48 #endif
Definition: File.hpp:55
This class implements file systems that are ZIP archives, employing the unzip library by Gilles Volla...
Definition: FileSys_ZipArchive_GV.hpp:21
~FileSystemZipArchiveGVT()
Destructor. Destroys the file system.
Definition: FileSys_ZipArchive_GV.cpp:62
Definition: FileSys.hpp:42
FileSystemZipArchiveGVT(const std::string &ArchiveName, const std::string &MountPoint, const std::string &Password="")
Constructor.
Definition: FileSys_ZipArchive_GV.cpp:14
InFileI * OpenRead(const std::string &FileName)
Opens the file with the given name for reading.
Definition: FileSys_ZipArchive_GV.cpp:71