/
FileTable.h
55 lines (45 loc) · 1.13 KB
/
FileTable.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
#ifndef _FILETABLE_H_
#define _FILETABLE_H_
#define TABLE_SIZE 1024
typedef struct
{
char *path;
unsigned int nPathLen;
unsigned char *handle;
bool bCached;
} FILE_ITEM;
typedef struct _FILE_TABLE
{
FILE_ITEM pItems[TABLE_SIZE];
_FILE_TABLE *pNext;
} FILE_TABLE;
typedef struct _CACHE_LIST
{
FILE_ITEM *pItem;
_CACHE_LIST *pNext;
} CACHE_LIST;
class CFileTable
{
public:
CFileTable();
~CFileTable();
unsigned long GetIDByPath(char *path);
unsigned char *GetHandleByPath(char *path);
char *GetPathByHandle(unsigned char *handle);
FILE_ITEM *FindItemByPath(char *path);
protected:
FILE_ITEM *AddItem(char *path);
private:
FILE_TABLE *m_pFirstTable, *m_pLastTable;
unsigned int m_nTableSize;
CACHE_LIST *m_pCacheList;
FILE_ITEM *GetItemByID(unsigned int nID);
void PutItemInCache(FILE_ITEM *pItem);
};
extern bool FileExists(char *path);
extern unsigned long GetFileID(char *path);
extern unsigned char *GetFileHandle(char *path);
extern char *GetFilePath(unsigned char *handle);
extern bool RenameFile(char *pathFrom, char *pathTo);
extern bool RemoveFile(char *path);
#endif