forked from igroglaz/srvmgr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
File.h
69 lines (54 loc) · 1.18 KB
/
File.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
#ifndef FILE_H_INCLUDED
#define FILE_H_INCLUDED
#include <string>
#include <vector>
#include <fstream>
#include <stdint.h>
class FileArchive
{
public:
struct Record
{
uint32_t Flags;
std::string Name;
uint32_t Length;
uint32_t Offset;
std::vector<Record> Children;
std::string ResourceName;
Record()
{
Flags = 2;
Name = "";
Length = 0;
Offset = 0;
}
};
bool Open(std::string filename, std::string directory);
const Record& GetRecord(std::string filename);
private:
std::string myFileName;
std::string myDirectoryName;
std::vector<Record> myRoot;
};
extern FileArchive Archives;
class File
{
public:
File();
bool Open(std::string filename);
void Close();
uint32_t Read(void* destination, uint32_t size);
void Seek(uint32_t position);
uint32_t GetPosition();
uint32_t GetLength();
uint32_t CalcCRC();
bool GetLine(std::string& line);
private:
bool myOpen;
std::string myName;
uint32_t myLength;
uint32_t myPosition;
uint32_t myOffset;
std::ifstream myStream;
};
#endif // FILE_H_INCLUDED