Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
mpqfile.h
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#define _CRT_SECURE_NO_DEPRECATE
7#ifndef _CRT_SECURE_NO_WARNINGS // fuck the police^Wwarnings
8#define _CRT_SECURE_NO_WARNINGS
9#endif
10
11#ifndef MPQ_H
12#define MPQ_H
13
14#include <string.h>
15#include <ctype.h>
16#include <vector>
17#include <iostream>
18#include <deque>
19#include "StormLib.h"
20
21#ifdef _WIN32
22#include <Windows.h> // mainly only HANDLE definition is required
23typedef __int64 int64;
24typedef __int32 int32;
25typedef __int16 int16;
26typedef __int8 int8;
27typedef unsigned __int64 uint64;
28typedef unsigned __int32 uint32;
29typedef unsigned __int16 uint16;
30typedef unsigned __int8 uint8;
31#else
32#include <stdint.h>
33#ifndef uint64_t
34#ifdef __linux__
35#include <linux/types.h>
36#endif
37#endif
38typedef int64_t int64;
39typedef int32_t int32;
40typedef int16_t int16;
41typedef int8_t int8;
42typedef uint64_t uint64;
43typedef uint32_t uint32;
44typedef uint16_t uint16;
45typedef uint8_t uint8;
46#endif
47
48using namespace std;
49
51{
52 //MPQHANDLE handle;
53 bool eof;
54 char *buffer;
55 size_t pointer,size;
56
57 // disable copying
58 MPQFile(const MPQFile &f);
59 void operator=(const MPQFile &f);
60
61public:
62 MPQFile(HANDLE mpq, const char* filename, bool warnNoExist = true); // filenames are not case sensitive
63 ~MPQFile() { close(); }
64 size_t read(void* dest, size_t bytes);
65 size_t getSize() { return size; }
66 size_t getPos() { return pointer; }
67 char* getBuffer() { return buffer; }
68 char* getPointer() { return buffer + pointer; }
69 bool isEof() { return eof; }
70 void seek(int offset);
71 void seekRelative(int offset);
72 void close();
73};
74
75inline void flipcc(char *fcc)
76{
77 char t;
78 t=fcc[0];
79 fcc[0]=fcc[3];
80 fcc[3]=t;
81 t=fcc[1];
82 fcc[1]=fcc[2];
83 fcc[2]=t;
84}
85
86#endif
std::int32_t int32
Definition Define.h:73
std::uint8_t uint8
Definition Define.h:79
std::uint32_t uint32
Definition Define.h:77
std::int8_t int8
Definition Define.h:75
std::uint64_t uint64
Definition Define.h:76
std::int64_t int64
Definition Define.h:72
std::uint16_t uint16
Definition Define.h:78
std::int16_t int16
Definition Define.h:74
size_t getSize()
Definition mpqfile.h:65
size_t read(void *dest, size_t bytes)
Definition mpqfile.cpp:58
MPQFile(const MPQFile &f)
char * buffer
Definition mpqfile.h:54
size_t pointer
Definition mpqfile.h:55
~MPQFile()
Definition mpqfile.h:63
char * getPointer()
Definition mpqfile.h:68
bool isEof()
Definition mpqfile.h:69
size_t size
Definition mpqfile.h:55
void close()
Definition mpqfile.cpp:87
size_t getPos()
Definition mpqfile.h:66
void seek(int offset)
Definition mpqfile.cpp:75
void seekRelative(int offset)
Definition mpqfile.cpp:81
char * getBuffer()
Definition mpqfile.h:67
bool eof
Definition mpqfile.h:53
void operator=(const MPQFile &f)
void flipcc(char *fcc)
Definition mpqfile.h:75