-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdriver.h
More file actions
35 lines (25 loc) · 738 Bytes
/
driver.h
File metadata and controls
35 lines (25 loc) · 738 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
34
35
#ifndef __IO_DRIVER_H__
#define __IO_DRIVER_H__
#include <cstdio>
#include <list>
using std::list;
#define PAGE_SIZE 24
class Driver {
public:
Driver();
~Driver();
void open(const char* filename);
void close();
list<unsigned int> alloc(unsigned int length);
bool readPage(unsigned int page_num, unsigned char* data, unsigned int* length);
unsigned int writePage(unsigned int page_num, unsigned char* data, unsigned int length);
void deletePage(unsigned int page_num);
static Driver* getInstance();
protected:
FILE* fp;
inline unsigned int getPagePositionOnFile(unsigned int page_num) {
return page_num * PAGE_SIZE;
}
unsigned char page_contents_buffer[PAGE_SIZE];
};
#endif