xoreos  0.0.5
zipfile.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos 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 xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef COMMON_ZIPFILE_H
26 #define COMMON_ZIPFILE_H
27 
28 #include <list>
29 #include <vector>
30 
31 #include <boost/noncopyable.hpp>
32 
33 #include "src/common/types.h"
34 #include "src/common/scopedptr.h"
35 #include "src/common/ustring.h"
36 
37 namespace Common {
38 
39 class SeekableReadStream;
40 
42 class ZipFile : boost::noncopyable {
43 public:
45  struct File {
48  };
49 
50  typedef std::list<File> FileList;
51 
53  ~ZipFile();
54 
56  const FileList &getFiles() const;
57 
59  size_t getFileSize(uint32 index) const;
60 
62  SeekableReadStream *getFile(uint32 index, bool tryNoCopy = false) const;
63 
64 private:
66  struct IFile {
69  };
70 
71  typedef std::vector<IFile> IFileList;
72 
74 
77 
80 
81  void load(SeekableReadStream &zip);
82 
84  uint32 compSize, uint32 realSize);
85 
86  const IFile &getIFile(uint32 index) const;
87  void getFileProperties(SeekableReadStream &zip, const IFile &file,
88  uint16 &compMethod, uint32 &compSize, uint32 &realSize) const;
89 };
90 
91 } // End of namespace Common
92 
93 #endif // COMMON_ZIPFILE_H
UString name
The file&#39;s name.
Definition: zipfile.h:46
Internal file information.
Definition: zipfile.h:66
Definition: 2dafile.h:39
A class holding an UTF-8 string.
Definition: ustring.h:48
ScopedPtr< SeekableReadStream > _zip
Definition: zipfile.h:73
A simple scoped smart pointer template.
SeekableReadStream * getFile(uint32 index, bool tryNoCopy=false) const
Return a stream of the file&#39;s contents.
Definition: zipfile.cpp:161
static SeekableReadStream * decompressFile(SeekableReadStream &zip, uint32 method, uint32 compSize, uint32 realSize)
Definition: zipfile.cpp:176
const FileList & getFiles() const
Return the list of files.
Definition: zipfile.cpp:121
ZipFile(SeekableReadStream *zip)
Definition: zipfile.cpp:37
uint16_t uint16
Definition: types.h:202
std::list< File > FileList
Definition: zipfile.h:50
A class encapsulating ZIP file access.
Definition: zipfile.h:42
uint32 size
The file&#39;s size.
Definition: zipfile.h:68
Low-level type definitions to handle fixed width types portably.
A scoped plain pointer, allowing pointer-y access and normal deletion.
Definition: scopedptr.h:120
size_t getFileSize(uint32 index) const
Return the size of a file.
Definition: zipfile.cpp:157
void load(SeekableReadStream &zip)
Definition: zipfile.cpp:46
Unicode string handling.
uint32_t uint32
Definition: types.h:204
FileList _files
External list of file names and types.
Definition: zipfile.h:76
IFileList _iFiles
Internal list of file offsets and sizes.
Definition: zipfile.h:79
std::vector< IFile > IFileList
Definition: zipfile.h:71
const IFile & getIFile(uint32 index) const
Definition: zipfile.cpp:125
uint32 offset
The offset of the file within the ZIP.
Definition: zipfile.h:67
void getFileProperties(SeekableReadStream &zip, const IFile &file, uint16 &compMethod, uint32 &compSize, uint32 &realSize) const
Definition: zipfile.cpp:132
Interface for a seekable & readable data stream.
Definition: readstream.h:265
uint32 index
The file&#39;s local index within the ZIP.
Definition: zipfile.h:47