aboutsummaryrefslogtreecommitdiff
path: root/lib/base/rawfile.h
blob: 1720d581981bc482343cf20bf1d8ce658553c658 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef __lib_base_rawfile_h
#define __lib_base_rawfile_h

#include <string>
#include <lib/base/idatasource.h>

class eRawFile: public iDataSource
{
	DECLARE_REF(eRawFile);
	eSingleLock m_lock;
public:
	eRawFile();
	~eRawFile();
	int open(const char *filename, int cached = 0);
	void setfd(int fd);
	int close();

	// iDataSource
	off_t lseek(off_t offset, int whence);
	ssize_t read(off_t offset, void *buf, size_t count);
	off_t length();
	int valid();
private:
	int m_fd;     /* for uncached */
	FILE *m_file; /* for cached */
	int m_cached;
	std::string m_basename;
	off_t m_splitsize, m_totallength, m_current_offset, m_base_offset, m_last_offset;
	int m_nrfiles;
	void scan();
	int m_current_file;
	int switchOffset(off_t off);

	off_t lseek_internal(off_t offset, int whence);
	FILE *openFileCached(int nr);
	int openFileUncached(int nr);
};

#endif