Subversion Repositories spk

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 cycrow 1
/*****************************************************************************
2
 
3
  clsFILE
4
  -------
5
 
6
  This is a class for handling files and memory maps of them.
7
 
8
  by yoda
9
 
10
  WWW:      y0da.cjb.net
11
  E-mail:   LordPE@gmx.net
12
 
13
  You are allowed to use this source code in your own projects if you mention
14
  my name.
15
 
16
*****************************************************************************/
17
 
18
#ifndef __File_h__
19
#define __File_h__
20
 
21
#include <windows.h>
22
 
23
//
24
// constants
25
//
26
// modes for GetFileHandle
27
#define F_OPENEXISTING_R     0
28
#define F_OPENEXISTING_RW    1
29
#define F_CREATENEW          2
30
#define F_TRUNCATE           3
31
 
32
//
33
// clsFILE class
34
//
35
class clsFILE
36
{
37
public:
38
	clsFILE();
39
	~clsFILE();
40
	BOOL          GetFileHandle(char *szFilePath, DWORD dwMode);
41
	BOOL          GetFileHandleWithMaxAccess(char* szFilePath);
42
	BOOL          Destroy();
43
	void          InitVars();
44
	HANDLE        GetHandle();
45
	BOOL          IsFileReadOnly();
46
	BOOL          MapFile();
47
	void*         GetMapPtr();
48
	BOOL          UnmapFile();
49
	BOOL          ReMapFile(DWORD dwNewSize);
50
	DWORD         GetMapSize();
51
	BOOL          IsMapped();
52
	DWORD         GetFSize();
53
	BOOL          FlushFileMap();
54
	static BOOL   FileExists(char* szFilePath);
55
	char*         GetFilePath();
56
	BOOL          Write(void* pBuff, DWORD dwc);
57
	BOOL          Read(void* pBuff, DWORD dwc);
58
	BOOL          SetFPointer(DWORD dwOff);
59
	BOOL          Truncate();
60
	void          SetMapPtrSize(void* ptr, DWORD dwSize);
61
 
62
private:
63
	DWORD         dwMapSize;
64
	void          *pMap;
65
	BOOL          bReadOnly;
66
	HANDLE        hFile;
67
	char          cFilePath[MAX_PATH];
68
};
69
 
70
#endif