File indexing completed on 2025-02-16 07:39:51
0001 /* 0002 SPDX-FileCopyrightText: 2006-2009 Sebastian Trueg <trueg@k3b.org> 0003 SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef _K3B_FILE_SPLITTER_H_ 0009 #define _K3B_FILE_SPLITTER_H_ 0010 0011 #include "k3b_export.h" 0012 0013 #include <QIODevice> 0014 #include <QString> 0015 0016 0017 namespace K3b { 0018 /** 0019 * QFile replacement which splits 0020 * big files according to the underlying file system's 0021 * maximum file size. 0022 * 0023 * The filename will be changed to include a counter 0024 * if the file has to be split like so: 0025 * 0026 * <pre> 0027 * filename.iso 0028 * filename.iso.001 0029 * filename.iso.002 0030 * ... 0031 * </pre> 0032 */ 0033 class LIBK3B_EXPORT FileSplitter : public QIODevice 0034 { 0035 Q_OBJECT 0036 0037 public: 0038 FileSplitter(); 0039 explicit FileSplitter( const QString& filename ); 0040 ~FileSplitter() override; 0041 0042 /** 0043 * Set the maximum file size. If this is set to 0 0044 * (the default) the max filesize is determined based on 0045 * the filesystem type. 0046 * 0047 * Be aware that setName will reset the max file size. 0048 */ 0049 void setMaxFileSize( qint64 size ); 0050 0051 QString name() const; 0052 0053 void setName( const QString& filename ); 0054 0055 bool open( OpenMode mode ) override; 0056 0057 void close() override; 0058 0059 virtual void flush(); 0060 0061 qint64 size() const override; 0062 0063 qint64 pos() const override; 0064 0065 /** 0066 * Not implemented 0067 */ 0068 bool seek( qint64 ) override; 0069 0070 bool atEnd() const override; 0071 0072 /** 0073 * Deletes all the split files. 0074 * Caution: Does remove all files that fit the naming scheme without any 0075 * additional checks. 0076 */ 0077 void remove(); 0078 0079 /** 0080 * \return \p true if the file is open in writable mode 0081 */ 0082 bool waitForBytesWritten( int msecs ) override; 0083 0084 /** 0085 * \return \p true if open and not at end 0086 */ 0087 bool waitForReadyRead( int msecs ) override; 0088 0089 protected: 0090 qint64 readData( char *data, qint64 maxlen ) override; 0091 qint64 writeData( const char *data, qint64 len ) override; 0092 0093 private: 0094 class Private; 0095 Private* d; 0096 }; 0097 } 0098 0099 #endif