-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmmfile.h
More file actions
33 lines (27 loc) · 946 Bytes
/
mmfile.h
File metadata and controls
33 lines (27 loc) · 946 Bytes
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
//-----------------------------------------------------------------------------
// File: mmfile.h
//
// Desc: Memory mapped file
//-----------------------------------------------------------------------------
#ifndef MMFILE_H
#define MMFILE_H
#include "file.h"
#include "win.h"
class mmfile_t : public file_t {
public:
mmfile_t() : file(INVALID_HANDLE_VALUE), map(INVALID_HANDLE_VALUE), view(0), view_size(0) {}
mmfile_t(const char* filename) : file(INVALID_HANDLE_VALUE), map(INVALID_HANDLE_VALUE),
view(0), view_size(0) { open(filename); }
~mmfile_t() { close(); }
uint size() { return view_size; }
ubyte* data() { return view; }
bool valid() { return (view != NULL); }
void close();
bool open(const char* filename);
protected:
HANDLE file; // Handle to the file object
HANDLE map; // Handle to the memory mapped file
ubyte* view; // Pointer to the files contents
uint view_size; // Total size of the archive
};
#endif