File indexing completed on 2025-03-16 04:29:30
0001 /* 0002 SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 #ifndef _K3B_DATATRACK_READER_H_ 0006 #define _K3B_DATATRACK_READER_H_ 0007 0008 #include "k3bthreadjob.h" 0009 0010 #include "k3bglobals.h" 0011 #include "k3bmsf.h" 0012 0013 class QIODevice; 0014 0015 namespace K3b { 0016 namespace Device { 0017 class Device; 0018 } 0019 0020 /** 0021 * This is a replacement for readcd. We need this since 0022 * it is not possible to influence the sector size used 0023 * by readcd and readcd is not very good to handle anyway. 0024 * 0025 * The sector size read is the following: 0026 * @li Mode1: 2048 bytes (only user data) 0027 * @li Mode2 Form1: 2056 bytes containing the subheader and the user data 0028 * @li Mode2 Form2: 2332 bytes containing the subheader and the user data 0029 * 0030 * Formless Mode2 sectors will not be read. 0031 */ 0032 class DataTrackReader : public ThreadJob 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 explicit DataTrackReader( JobHandler*, QObject* parent = 0 ); 0038 ~DataTrackReader() override; 0039 0040 enum ReadSectorSize { 0041 AUTO = K3b::SectorSizeAuto, 0042 MODE1 = K3b::SectorSizeData2048, 0043 MODE2FORM1 = K3b::SectorSizeData2048Subheader, 0044 MODE2FORM2 = K3b::SectorSizeData2324Subheader 0045 }; 0046 0047 void setSectorSize( ReadSectorSize size ); 0048 0049 void setDevice( Device::Device* ); 0050 0051 void setImagePath( const QString& p ); 0052 0053 /** 0054 * @param start the first sector to be read 0055 * @end the last sector to be read 0056 */ 0057 void setSectorRange( const Msf& start, const Msf& end ); 0058 void setRetries( int ); 0059 0060 /** 0061 * If true unreadable sectors will be replaced by zero data to always 0062 * maintain the track length. 0063 */ 0064 void setIgnoreErrors( bool b ); 0065 0066 void setNoCorrection( bool b ); 0067 0068 void writeTo( QIODevice* ioDev ); 0069 0070 private: 0071 bool run() override; 0072 0073 int read( unsigned char* buffer, unsigned long sector, unsigned int len ); 0074 bool retryRead( unsigned char* buffer, unsigned long startSector, unsigned int len ); 0075 bool setErrorRecovery( Device::Device* dev, int code ); 0076 0077 class Private; 0078 Private* const d; 0079 }; 0080 } 0081 0082 #endif