Commit b2ad7011 authored by Henrique Pinto's avatar Henrique Pinto
Browse files

* Use a list of variants instead of a string list for extracting files

   (not complete yet, though). The reason for this is that converting the
   entry name to a QString and then back to a char* might not work, since
   entry names might be in a crazy weirdo made up encoding we can't guess.
   So, some backends might choose to store a QByteArray or any other thing
   supported by a QVariant as the "original name".


svn path=/branches/work/libarchive-based-ark/ark/; revision=686041
parent 4b9e05b0
......@@ -58,7 +58,7 @@ class ReadOnlyArchiveInterface: public QObject
virtual bool open() { return true; }
virtual bool list() = 0;
virtual bool copyFiles( const QStringList & files, const QString & destinationDirectory ) = 0;
virtual bool copyFiles( const QList<QVariant> & files, const QString & destinationDirectory ) = 0;
protected:
void error( const QString & message, const QString & details );
......
......@@ -48,7 +48,7 @@ void ListingJob::run()
m_success = m_helper->getTheListing();
}
ExtractionJob::ExtractionJob( ReadOnlyArchiveInterface *archive, const QStringList & files, const QString & destinationDirectory, QObject *parent )
ExtractionJob::ExtractionJob( ReadOnlyArchiveInterface *archive, const QList<QVariant> & files, const QString & destinationDirectory, QObject *parent )
: ThreadWeaver::Job( parent ), m_archive( archive ), m_files( files ), m_destinationDirectory( destinationDirectory ),
m_helper( 0 ), m_success( false )
{
......
......@@ -61,7 +61,7 @@ class ExtractionJob: public ThreadWeaver::Job
{
Q_OBJECT
public:
ExtractionJob( ReadOnlyArchiveInterface *archive, const QStringList & files, const QString & destinationDirectory, QObject *parent = 0 );
ExtractionJob( ReadOnlyArchiveInterface *archive, const QList<QVariant> & files, const QString & destinationDirectory, QObject *parent = 0 );
~ExtractionJob();
bool success() const { return m_success; }
......@@ -74,7 +74,7 @@ class ExtractionJob: public ThreadWeaver::Job
private:
ReadOnlyArchiveInterface *m_archive;
QStringList m_files;
QList<QVariant> m_files;
QString m_destinationDirectory;
ArchiveJobHelper *m_helper;
bool m_success;
......
......@@ -85,7 +85,13 @@ void LibArchiveHandler::remove( const QStringList & )
void LibArchiveHandler::extractFiles( const QStringList & files, const QString& destinationDir )
{
ExtractionJob *job = new ExtractionJob( new LibArchiveInterface( fileName(), this ), files, destinationDir, this );
QList<QVariant> entries;
foreach( QString file, files )
{
entries << file;
}
ExtractionJob *job = new ExtractionJob( new LibArchiveInterface( fileName(), this ), entries, destinationDir, this );
connect( job, SIGNAL( done( ThreadWeaver::Job* ) ),
this, SLOT( extractionDone( ThreadWeaver::Job * ) ) );
ThreadWeaver::Weaver::instance()->enqueue( job );
......@@ -156,7 +162,7 @@ bool LibArchiveInterface::list()
return archive_read_finish( arch ) == ARCHIVE_OK;
}
bool LibArchiveInterface::copyFiles( const QStringList & files, const QString & destinationDirectory )
bool LibArchiveInterface::copyFiles( const QList<QVariant> & files, const QString & destinationDirectory )
{
QDir::setCurrent( destinationDirectory );
......@@ -164,7 +170,12 @@ bool LibArchiveInterface::copyFiles( const QStringList & files, const QString &
struct archive *arch, *writer;
struct archive_entry *entry;
QStringList entries = files;
QStringList entries;
foreach( QVariant f, files )
{
entries << f.toString();
}
arch = archive_read_new();
if ( !arch )
......
......@@ -42,7 +42,7 @@ class LibArchiveInterface: public ReadOnlyArchiveInterface
~LibArchiveInterface();
bool list();
bool copyFiles( const QStringList & files, const QString & destinationDirectory );
bool copyFiles( const QList<QVariant> & files, const QString & destinationDirectory );
private:
int extractionFlags() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment