AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
FileLoader Class Reference

#include "loadlib.h"

Inheritance diagram for FileLoader:
ADT_file WDT_file

Public Member Functions

virtual bool prepareLoadedData ()
 
uint8GetData ()
 
uint32 GetDataSize ()
 
 FileLoader ()
 
 ~FileLoader ()
 
bool loadFile (std::string const &filename, bool log=true)
 
virtual void free ()
 
virtual bool prepareLoadedData ()
 
uint8GetData ()
 
uint32 GetDataSize ()
 
 FileLoader ()
 
 ~FileLoader ()
 
bool loadFile (std::string const &filename, bool log=true)
 
virtual void free ()
 

Public Attributes

file_MVERversion
 

Private Attributes

uint8data
 
uint32 data_size
 

Detailed Description

Constructor & Destructor Documentation

◆ FileLoader() [1/2]

FileLoader::FileLoader ( )
29{
30 data = nullptr;
31 data_size = 0;
32 version = nullptr;
33}
uint32 data_size
Definition: loadlib.h:50
file_MVER * version
Definition: loadlib.h:56
uint8 * data
Definition: loadlib.h:49

References data, data_size, and version.

◆ ~FileLoader() [1/2]

FileLoader::~FileLoader ( )
36{
37 free();
38}
virtual void free()
Definition: loadlib.cpp:76

References free().

◆ FileLoader() [2/2]

FileLoader::FileLoader ( )

◆ ~FileLoader() [2/2]

FileLoader::~FileLoader ( )

Member Function Documentation

◆ free() [1/2]

void FileLoader::free ( )
virtual

Reimplemented in ADT_file, and WDT_file.

77{
78 delete[] data;
79 data = nullptr;
80 data_size = 0;
81 version = nullptr;
82}

References data, data_size, and version.

Referenced by ADT_file::free(), WDT_file::free(), loadFile(), and ~FileLoader().

◆ free() [2/2]

virtual void FileLoader::free ( )
virtual

Reimplemented in ADT_file, and WDT_file.

◆ GetData() [1/2]

uint8 * FileLoader::GetData ( )
inline
53{return data;}

References data.

Referenced by ADT_file::prepareLoadedData().

◆ GetData() [2/2]

uint8 * FileLoader::GetData ( )
inline
71{return data;}

References data.

◆ GetDataSize() [1/2]

uint32 FileLoader::GetDataSize ( )
inline
54{return data_size;}

References data_size.

◆ GetDataSize() [2/2]

uint32 FileLoader::GetDataSize ( )
inline
72{return data_size;}

References data_size.

◆ loadFile() [1/2]

bool FileLoader::loadFile ( std::string const &  filename,
bool  log = true 
)
41{
42 free();
43 MPQFile mf(fileName.c_str());
44 if (mf.isEof())
45 {
46 if (log)
47 printf("No such file %s\n", fileName.c_str());
48 return false;
49 }
50
51 data_size = mf.getSize();
52
53 data = new uint8 [data_size];
54 mf.read(data, data_size);
55 mf.close();
57 return true;
58
59 printf("Error loading %s", fileName.c_str());
60 mf.close();
61 free();
62 return false;
63}
std::uint8_t uint8
Definition: Define.h:109
virtual bool prepareLoadedData()
Definition: loadlib.cpp:65
Definition: mpq_libmpq04.h:75

References MPQFile::close(), data, data_size, free(), MPQFile::getSize(), MPQFile::isEof(), prepareLoadedData(), and MPQFile::read().

Referenced by ConvertADT(), and ExtractMapsFromMpq().

◆ loadFile() [2/2]

bool FileLoader::loadFile ( std::string const &  filename,
bool  log = true 
)

◆ prepareLoadedData() [1/2]

bool FileLoader::prepareLoadedData ( )
virtual

Reimplemented in ADT_file, and WDT_file.

66{
67 // Check version
69 if (version->fcc != MverMagic.fcc)
70 return false;
72 return false;
73 return true;
74}
u_map_fcc MverMagic
Definition: loadlib.cpp:26
uint32 fcc
Definition: loadlib.h:29
Definition: loadlib.h:37
uint32 ver
Definition: loadlib.h:44
uint32 fcc
Definition: loadlib.h:40
#define FILE_FORMAT_VERSION
Definition: loadlib.h:49

References data, u_map_fcc::fcc, file_MVER::fcc, FILE_FORMAT_VERSION, MverMagic, file_MVER::ver, and version.

Referenced by loadFile(), ADT_file::prepareLoadedData(), and WDT_file::prepareLoadedData().

◆ prepareLoadedData() [2/2]

virtual bool FileLoader::prepareLoadedData ( )
virtual

Reimplemented in ADT_file, and WDT_file.

Member Data Documentation

◆ data

uint8 * FileLoader::data
private

◆ data_size

uint32 FileLoader::data_size
private

◆ version