ich hab mal angefangen, eine QT-Version zu schreiben, hab dann aber aufgehört, weil mir das System abgeschmiert ist. Es sollte theoretissch funktionieren, es ist nur noch ein Segfault drin. GDB sagt, das irgendwo strlen von libc.so.6 aufgerufen wird. Vielleicht will ja mla jmd. den Quelltext als Basis nehmen und weitermachen.
Code:
#include <qprogressdialog.h>
#include <qapplication.h>
#include <qprocess.h>
#include <iostream>
class Untar : public QProgressDialog
{
Q_OBJECT
public:
Untar(QString filename);
~Untar(){};
public slots:
void cprocsst();
void procsst();
void untar();
protected:
int filecount;
int currentfile;
QString workingdir, singlefilename;
};
Untar::Untar(QString filename) : QProgressDialog()
{
filecount = 0;
currentfile = 0;
workingdir = filename.mid(0,filename.findRev("/"));
singlefilename = filename.mid(filename.findRev("/"));
connect(this, SIGNAL(cancelled()), qApp, SLOT(quit()));
QProcess* countproc = new QProcess(this);
countproc->addArgument("tar");
countproc->addArgument(((filename.endsWith(".bz2")) ? "-jt": "-zt"));
countproc->addArgument(filename);
connect(countproc, SIGNAL(readyReadStdout()), this, SLOT(cprocsst()));
connect(countproc, SIGNAL(processExited()), this, SLOT(untar()));
connect(countproc, SIGNAL(readyReadStderr()), qApp, SLOT(quit()));
if(! countproc->start())
qApp->quit();
}
void Untar::cprocsst()
{
filecount++;
qDebug("void Untar::cprocsst()");
}
void Untar::procsst()
{
setProgress(currentfile * 100 / filecount);
}
void Untar::untar()
{
qDebug("Untar started");
QProcess* proc = new QProcess(this);
proc->addArgument("tar");
proc->addArgument((singlefilename.endsWith(".bz2") ? "-jxf": "-zxf"));
proc->addArgument(singlefilename);
proc->setWorkingDirectory(workingdir);
connect(proc, SIGNAL(readyReadStdout()), this, SLOT(procsst()));
connect(proc, SIGNAL(processExited()), qApp, SLOT(quit()));
proc->start();
}
#include "untar.moc.cpp"
int main(int argc, char **argv)
{
if(argc != 2)
return(0);
QApplication app(argc, argv);
Untar t(app.argv()[1]);
t.resize(400,100);
app.setMainWidget(&t);
t.show();
return(app.exec());
}
Lesezeichen