-
Notifications
You must be signed in to change notification settings - Fork 0
/
GMemFile.h
72 lines (52 loc) · 1.3 KB
/
GMemFile.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
// GMemFile by fastman92
#pragma once
#include <stddef.h>
class GMemFile
{
public:
typedef size_t tPosition;
private:
char* Ptr;
tPosition Pos;
tPosition RealSize;
tPosition SizeLimit;
public:
// Constructor
GMemFile();
// Opens file from memory.
void Open(void *Ptr, tPosition RealSize, tPosition SizeLimit = -1);
// Closes a file
void Close();
// Reads to memory
tPosition Read(void* Ptr, size_t Size);
// Reads NULL terminated string
void ReadNULLterminatedString(char* str);
// Reads 4 byte aligned NULL terminated string
void Read4byteAlignedNULLterminatedString(char* str);
// Reads one ANSI character
char ReadC();
/*
// Reads one Unicode character
wchar_t GMemFile::ReadWideChar();
*/
// Writes to memory file
void Write(const void* Ptr, size_t Size);
// Writes string to memory file
void WriteString(const char* str);
// Writes 4 byte aligned NULL terminated string
bool Writes4byteAlignedNULLterminatedString(const char* str);
// Seek to certain position
bool Seek(size_t offset, int origin);
// Check End-of-File indicator
bool isEOF();
// Returns current position
tPosition Tell();
// Gets pointer to file
void* GetPtr();
// Gets Ptr + current position
void* GetCurPtr();
// Gets filesize
size_t GetSize();
// Sets filesize
bool SetSize(tPosition filesize);
};