1 #ifndef __SPLITFILE_HH_INCLUDED__ 2 #define __SPLITFILE_HH_INCLUDED__ 3 4 #include <QFile> 5 #include <QVector> 6 #include <QString> 7 8 #include <vector> 9 #include <string> 10 11 namespace SplitFile 12 { 13 14 using std::vector; 15 using std::string; 16 17 // Class for work with split files 18 19 class SplitFile 20 { 21 protected: 22 23 QVector< QFile * > files; 24 QVector< quint64 > offsets; 25 int currentFile; 26 27 void appendFile( const QString & name ); 28 29 public: 30 31 SplitFile(); 32 ~SplitFile(); 33 34 virtual void setFileName( const QString & name ) = 0; 35 void getFilenames( vector< string > & names ) const; 36 bool open( QFile::OpenMode mode ); 37 void close(); 38 bool seek( quint64 pos ); 39 qint64 read( char * data, qint64 maxSize ); 40 QByteArray read( qint64 maxSize ); 41 bool getChar( char * c ); size() const42 qint64 size() const 43 { return files.isEmpty() ? 0 : offsets.last() + files.last()->size(); } exists() const44 bool exists() const 45 { return !files.isEmpty(); } 46 qint64 pos() const; 47 }; 48 49 } // namespace SplitFile 50 51 #endif // __SPLITFILE_HH_INCLUDED__ 52