TrinityCore
loadlib.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef LOAD_LIB_H
19#define LOAD_LIB_H
20
21#include "Define.h"
22#include "CascHandles.h"
23#include <map>
24#include <memory>
25#include <string>
26
27#define FILE_FORMAT_VERSION 18
28
29#pragma pack(push, 1)
30
32{
33 char fcc_txt[4];
35};
36
37//
38// File version chunk
39//
41{
42 union{
44 char fcc_txt[4];
45 };
48};
49
51{
54 char FileList[1];
55};
56
58{
59public:
60 FileChunk(uint8* data_, uint32 size_) : data(data_), size(size_) { }
61 ~FileChunk();
62
65
66 template<class T>
67 T* As() { return (T*)data; }
68 void parseSubChunks();
69 std::multimap<std::string, FileChunk*> subchunks;
70 FileChunk* GetSubChunk(std::string const& name);
71};
72
74{
75public:
78
79 uint8 *GetData() { return data; }
81
83 virtual ~ChunkedFile();
84 bool prepareLoadedData();
85 bool loadFile(std::shared_ptr<CASC::Storage const> mpq, std::string const& fileName, bool log = true);
86 bool loadFile(std::shared_ptr<CASC::Storage const> mpq, uint32 fileDataId, std::string const& description, bool log = true);
87 void free();
88
89 void parseChunks();
90 std::multimap<std::string, FileChunk*> chunks;
91 FileChunk* GetChunk(std::string const& name);
92};
93
94#pragma pack(pop)
95
96#endif
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
void free()
Definition: loadlib.cpp:105
virtual ~ChunkedFile()
Definition: loadlib.cpp:31
FileChunk * GetChunk(std::string const &name)
Definition: loadlib.cpp:168
uint8 * data
Definition: loadlib.h:76
void parseChunks()
Definition: loadlib.cpp:140
std::multimap< std::string, FileChunk * > chunks
Definition: loadlib.h:90
uint32 GetDataSize()
Definition: loadlib.h:80
bool loadFile(std::shared_ptr< CASC::Storage const > mpq, std::string const &fileName, bool log=true)
Definition: loadlib.cpp:36
uint8 * GetData()
Definition: loadlib.h:79
bool prepareLoadedData()
Definition: loadlib.cpp:90
uint32 data_size
Definition: loadlib.h:77
~FileChunk()
Definition: loadlib.cpp:177
uint32 size
Definition: loadlib.h:64
void parseSubChunks()
Definition: loadlib.cpp:185
uint8 * data
Definition: loadlib.h:63
T * As()
Definition: loadlib.h:67
FileChunk(uint8 *data_, uint32 size_)
Definition: loadlib.h:60
std::multimap< std::string, FileChunk * > subchunks
Definition: loadlib.h:69
FileChunk * GetSubChunk(std::string const &name)
Definition: loadlib.cpp:212
uint32 size
Definition: loadlib.h:46
char fcc_txt[4]
Definition: loadlib.h:44
uint32 ver
Definition: loadlib.h:47
uint32 fcc
Definition: loadlib.h:43
uint32 size
Definition: loadlib.h:53
u_map_fcc fcc
Definition: loadlib.h:52
char FileList[1]
Definition: loadlib.h:54
uint32 fcc
Definition: loadlib.h:34
char fcc_txt[4]
Definition: loadlib.h:33