zip_reader.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2015 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 */
28
29
30 #pragma once
31
32 #include <memory>
33 #include "../System/cl_platform.h"
34 #include <vector>
35
36 namespace clan
37 {
40
41 class IODevice;
42 class ZipReader_Impl;
43
45 class ZipReader
46 {
49
50 public:
51
55 ZipReader(IODevice &input);
56
60
61 public:
63
67 bool read_local_file_header(bool allow_data_descriptor = false);
68
70 std::string get_filename();
71
73 bool has_data_descriptor() const;
74
76 int64_t get_compressed_size() const;
77
79 int64_t get_uncompressed_size() const;
80
82 void set_data_descriptor_data(int64_t compressed_size, int64_t uncompressed_size, uint32_t crc32);
83
85 int64_t read_file_data(void *data, int64_t size, bool read_all = true);
86
90
91 private:
92 std::shared_ptr<ZipReader_Impl> impl;
94 };
95
96 }
97
clan
Definition: clanapp.h:35
clan::ZipReader::get_compressed_size
int64_t get_compressed_size() const
Returns the compressed size of the file entry.
clan::IODevice
I/O Device interface.
Definition: iodevice.h:50
clan::ZipReader
Zip file reader.
Definition: zip_reader.h:45
clan::ZipReader::read_file_data
int64_t read_file_data(void *data, int64_t size, bool read_all=true)
Reads some file data from the zip file.
clan::ZipReader::set_data_descriptor_data
void set_data_descriptor_data(int64_t compressed_size, int64_t uncompressed_size, uint32_t crc32)
Informs the zip reader what the data descriptor contains.
clan::StyleTokenType::string
@ keyword
clan::ZipReader::get_filename
std::string get_filename()
Returns the file name that was stored in the local file header.
clan::ZipReader::ZipReader
ZipReader(IODevice &input)
Constructs a ZipReader.
clan::ZipReader::has_data_descriptor
bool has_data_descriptor() const
Returns true if the file entry is followed by a data descriptor.
clan::ZipReader::read_local_file_header
bool read_local_file_header(bool allow_data_descriptor=false)
Begins reading a file entry in the zip file.
clan::ZipReader::get_uncompressed_size
int64_t get_uncompressed_size() const
Returns the uncompressed size of the file entry.