aboutsummaryrefslogtreecommitdiff
path: root/Src/external_dependencies/openmpt-trunk/unarchiver/unarchiver.h
blob: 83d73701c69ec0be68dc7e06657a7a96ca7c379b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * unarchiver.h
 * ------------
 * Purpose: archive loader
 * Notes  : (currently none)
 * Authors: OpenMPT Devs
 * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
 */

#pragma once

#include "openmpt/all/BuildSettings.hpp"

#include "../common/FileReader.h"

#include "archive.h"

#if (defined(MPT_WITH_ZLIB) && defined(MPT_WITH_MINIZIP)) || defined(MPT_WITH_MINIZ)
#include "unzip.h"
#endif
#ifdef MPT_WITH_LHASA
#include "unlha.h"
#endif
#if defined(MPT_WITH_ZLIB) || defined(MPT_WITH_MINIZ)
#include "ungzip.h"
#endif
#ifdef MPT_WITH_UNRAR
#include "unrar.h"
#endif
#ifdef MPT_WITH_ANCIENT
#include "unancient.h"
#endif


OPENMPT_NAMESPACE_BEGIN


class CUnarchiver : public IArchive
{

private:

	IArchive *impl;

	FileReader inFile;

	ArchiveBase emptyArchive;
#if (defined(MPT_WITH_ZLIB) && defined(MPT_WITH_MINIZIP)) || defined(MPT_WITH_MINIZ)
	CZipArchive zipArchive;
#endif
#ifdef MPT_WITH_LHASA
	CLhaArchive lhaArchive;
#endif
#if defined(MPT_WITH_ZLIB) || defined(MPT_WITH_MINIZ)
	CGzipArchive gzipArchive;
#endif
#ifdef MPT_WITH_UNRAR
	CRarArchive rarArchive;
#endif
#ifdef MPT_WITH_ANCIENT
	CAncientArchive ancientArchive;
#endif

public:

	CUnarchiver(FileReader &file);
	~CUnarchiver() override;

	bool IsArchive() const override;
	mpt::ustring GetComment() const override;
	bool ExtractFile(std::size_t index) override;
	FileReader GetOutputFile() const override;
	std::size_t size() const override;
	IArchive::const_iterator begin() const override;
	IArchive::const_iterator end() const override;
	const ArchiveFileInfo & operator [] (std::size_t index) const override;

public:

	static const std::size_t failIndex = (std::size_t)-1;

	std::size_t FindBestFile(const std::vector<const char *> &extensions);
	bool ExtractBestFile(const std::vector<const char *> &extensions);

};


OPENMPT_NAMESPACE_END