forked from goldendict/goldendict
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsplitfile.hh
51 lines (38 loc) · 994 Bytes
/
splitfile.hh
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
#ifndef __SPLITFILE_HH_INCLUDED__
#define __SPLITFILE_HH_INCLUDED__
#include <QFile>
#include <QVector>
#include <QString>
#include <vector>
#include <string>
namespace SplitFile
{
using std::vector;
using std::string;
// Class for work with split files
class SplitFile
{
protected:
QVector< QFile * > files;
QVector< quint64 > offsets;
int currentFile;
void appendFile( const QString & name );
public:
SplitFile();
~SplitFile();
virtual void setFileName( const QString & name ) = 0;
void getFilenames( vector< string > & names ) const;
bool open( QFile::OpenMode mode );
void close();
bool seek( quint64 pos );
qint64 read( char * data, qint64 maxSize );
QByteArray read( qint64 maxSize );
bool getChar( char * c );
qint64 size() const
{ return files.isEmpty() ? 0 : offsets.last() + files.last()->size(); }
bool exists() const
{ return !files.isEmpty(); }
qint64 pos() const;
};
} // namespace SplitFile
#endif // __SPLITFILE_HH_INCLUDED__