-
Notifications
You must be signed in to change notification settings - Fork 0
/
ResourceFile.h
78 lines (63 loc) · 1.91 KB
/
ResourceFile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "stdafx.h"
// Title: Resource File Manager
// Version: 1.0
// Date: 2011-03-16
// Description: Allows the user to pack multiple files into one file for easy storage. Often used by game developers to pack resources into a single file.
// Author: Joel Verhagen
// Website: http://www.joelverhagen.com
// Licensing: Do whatever the heck you want with it. Golly, you don't even need to credit me if you don't want. Just don't say you originally wrote it. That would just make me sad.
#ifndef RESOURCEFILE_H
#define RESOURCEFILE_H
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <iostream>
using namespace std;
#include "order32.h"
class ResourceFileEntry
{
private:
string myName;
string myFilePath;
unsigned int myFileSize;
unsigned int myOffset;
public:
ResourceFileEntry(string name, string filePath, unsigned int fileSize);
string name();
string filePath();
unsigned int fileSize();
unsigned int offset();
void setOffset(unsigned int offset);
};
class ResourceFileBase
{
public:
static unsigned int magicWord;
ResourceFileBase(string filePath);
vector<string> getEntryNames();
protected:
bool myReady;
string myFilePath;
map<string, ResourceFileEntry *> myEntries;
};
class ResourceFileWriter : public ResourceFileBase
{
public:
ResourceFileWriter(string filePath);
bool write();
bool addEntry(string entryName, string entryFilePath);
private:
int getHeaderSize();
void writeNumber(ofstream &outputFile, unsigned int number);
};
class ResourceFileReader : public ResourceFileBase
{
public:
ResourceFileReader(string filePath);
bool read();
bool ResourceFileReader::deleteEntries();
unsigned int getEntryFileSize(const string &entryName);
char * getFile(const string &entryName);
};
#endif