File size: 951 Bytes
b6bd94d |
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 |
#pragma once
#include <QFile>
#include <QList>
#include <vector>
#include <string>
namespace SplitFile {
using std::vector;
using std::string;
// Class for work with split files
class SplitFile
{
protected:
QList< QFile * > files;
QList< quint64 > offsets;
// TODO: rename currentFile (?)
int currentFile;
void appendFile( const QString & name );
public:
SplitFile();
~SplitFile();
virtual void setFileName( const QString & name ) = 0;
void getFilenames( vector< string > & names ) const;
int getCurrentFile() 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
|