-
Notifications
You must be signed in to change notification settings - Fork 17
/
FileMapping.h
54 lines (42 loc) · 792 Bytes
/
FileMapping.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
// 120111
#ifndef __FileMapping_h__
#define __FileMapping_h__
#include <windows.h>
#ifdef _MSC_VER
typedef __int64 int64;
typedef unsigned __int64 uint64;
#else
typedef long long int64;
typedef unsigned long long uint64;
#endif
class FileMapping
{
public:
enum ReadHint
{
RANDOM = 0,
SEQUENTIAL,
};
public:
FileMapping();
~FileMapping();
bool Open(const wchar_t * path, ReadHint rhint = RANDOM);
void Close();
void Unmap();
void * Read(uint64 addr, size_t len, size_t * revlen);
size_t GetBlockBytes() const;
uint64 GetFileLen() const;
private:
HANDLE m_hFileMap;
uint64 m_qwFileSize;
size_t m_dwGran;
size_t m_dwBlockBytes;
void *m_pMapped;
uint64 m_qwMappedOffset;
uint64 m_qwMappedBlockSize;
#ifdef _DEBUG
public:
size_t m_ReadCount;
#endif
};
#endif