summaryrefslogtreecommitdiff
path: root/util/mmap.h
blob: 6b8b8926373a48471d6a5ea1b23224b122afd1e7 (plain)
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
// mmap.h

#pragma once

class MemoryMappedFile {
public:
	static void closeAllFiles();
	MemoryMappedFile();
	~MemoryMappedFile(); /* closes the file if open */
	void close();

	/* only smart enough right now to deal with files of a fixed length. 
	   creates if DNE
	*/
	void* map(const char *filename, int length);

	void flush(bool sync);

	void* viewOfs() { return view; }

private:
	HANDLE fd;
	HANDLE maphandle;
	void *view;
	int len;
};