TrinityCore
Loading...
Searching...
No Matches
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
56
58{
59public:
60 FileChunk(uint8* data_, uint32 size_) : data(data_), size(size_) { }
62
65
66 template<class T>
67 T* As() const { return (T*)data; }
68 void parseSubChunks();
69 std::multimap<std::string_view, FileChunk> subchunks;
70 FileChunk const* GetSubChunk(std::string_view name) const;
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_view, FileChunk> chunks;
91 FileChunk const* GetChunk(std::string_view name) const;
92};
93
94#pragma pack(pop)
95
96#endif
uint8_t uint8
Definition Define.h:156
uint32_t uint32
Definition Define.h:154
void free()
Definition loadlib.cpp:100
virtual ~ChunkedFile()
Definition loadlib.cpp:28
uint8 * data
Definition loadlib.h:76
void parseChunks()
Definition loadlib.cpp:132
uint32 GetDataSize()
Definition loadlib.h:80
FileChunk const * GetChunk(std::string_view name) const
Definition loadlib.cpp:158
bool loadFile(std::shared_ptr< CASC::Storage const > mpq, std::string const &fileName, bool log=true)
Definition loadlib.cpp:33
uint8 * GetData()
Definition loadlib.h:79
bool prepareLoadedData()
Definition loadlib.cpp:87
std::multimap< std::string_view, FileChunk > chunks
Definition loadlib.h:90
uint32 data_size
Definition loadlib.h:77
T * As() const
Definition loadlib.h:67
uint32 size
Definition loadlib.h:64
std::multimap< std::string_view, FileChunk > subchunks
Definition loadlib.h:69
void parseSubChunks()
Definition loadlib.cpp:169
uint8 * data
Definition loadlib.h:63
FileChunk(uint8 *data_, uint32 size_)
Definition loadlib.h:60
FileChunk const * GetSubChunk(std::string_view name) const
Definition loadlib.cpp:194
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