-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRFile.h
48 lines (34 loc) · 858 Bytes
/
RFile.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
#ifndef __rfile_h_
#define __rfile_h_
#include <string>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
class RFile
{
public:
static int BSZ,BMASK; // block size, must be a power of two
RFile(const std::string& filename);
virtual ~RFile() ;
// generic file operations
virtual size_t size();
virtual size_t read(void *buf);
virtual void seek(size_t pos);
// compression
virtual std::string CompressionInfo() { return "None"; }
static void InitBufSize();
// RFile helpers
bool Reopen();
void ShowError();
size_t read2(void *buf, size_t size);
protected:
int m_fh;
std::string m_fn;
size_t m_ptr;
bool m_didreopen;
bool m_diderror;
void seek2(off_t pos, int how);
size_t pos();
};
#endif