TrinityCore
cascfile.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#define _CRT_SECURE_NO_DEPRECATE
19#ifndef _CRT_SECURE_NO_WARNINGS // fuck the police^Wwarnings
20#define _CRT_SECURE_NO_WARNINGS
21#endif
22
23#ifndef MPQ_H
24#define MPQ_H
25
26#include "Define.h"
27#include "CascHandles.h"
28#include <memory>
29#include <string>
30#include <utility>
31
33{
34 bool eof;
35 char *buffer;
36 size_t pointer,size;
37
38 // disable copying
39 CASCFile(const CASCFile &f) = delete;
40 CASCFile& operator=(const CASCFile &f) = delete;
41
42public:
43 CASCFile(std::shared_ptr<CASC::Storage const> casc, const char* filename, bool warnNoExist = true); // filenames are not case sensitive
44 CASCFile(std::shared_ptr<CASC::Storage const> casc, uint32 fileDataId, std::string const& description, bool warnNoExist = true);
46 void init(CASC::File* file, const char* description);
47 size_t read(void* dest, size_t bytes);
48 size_t getSize() { return size; }
49 size_t getPos() { return pointer; }
50 char* getBuffer() { return buffer; }
51 char* getPointer() { return buffer + pointer; }
52 bool isEof() { return eof; }
53 void seek(int offset);
54 void seekRelative(int offset);
55 void close();
56};
57
58inline void flipcc(char *fcc)
59{
60 std::swap(fcc[0], fcc[3]);
61 std::swap(fcc[1], fcc[2]);
62}
63
64#endif
uint32_t uint32
Definition: Define.h:142
void flipcc(char *fcc)
Definition: cascfile.h:58
char * buffer
Definition: cascfile.h:35
~CASCFile()
Definition: cascfile.h:45
bool eof
Definition: cascfile.h:34
void seekRelative(int offset)
Definition: cascfile.cpp:105
bool isEof()
Definition: cascfile.h:52
CASCFile(const CASCFile &f)=delete
char * getPointer()
Definition: cascfile.h:51
void seek(int offset)
Definition: cascfile.cpp:99
size_t size
Definition: cascfile.h:36
size_t read(void *dest, size_t bytes)
Definition: cascfile.cpp:80
size_t pointer
Definition: cascfile.h:36
size_t getPos()
Definition: cascfile.h:49
char * getBuffer()
Definition: cascfile.h:50
CASCFile & operator=(const CASCFile &f)=delete
size_t getSize()
Definition: cascfile.h:48
void init(CASC::File *file, const char *description)
Definition: cascfile.cpp:58
void close()
Definition: cascfile.cpp:111