From 05e1fce300224da0c7c8021496c3c9483b2e7c4e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mikko=20Kein=C3=A4nen?= Date: Wed, 20 Oct 2010 00:49:16 +0300 Subject: [PATCH] Cleaning extracted files from tmp folder. --- src/utils/emuhelper.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/utils/emuhelper.cpp b/src/utils/emuhelper.cpp index ee92899..8beec34 100644 --- a/src/utils/emuhelper.cpp +++ b/src/utils/emuhelper.cpp @@ -18,6 +18,7 @@ // along with EmuFront. If not, see . #include +#include #include #include "emuhelper.h" #include "unziphelper.h" @@ -41,6 +42,8 @@ void EmuHelper::launch(const Executable * ex, QList micLi throw EmuFrontException(tr("No media image containers available!")); } + QString tmp = "/tmp/"; // TODO: do this configurable! + // extract the media image container to tmp folder // (TODO: tmp folder configuration) foreach(MediaImageContainer *mic, micList) { @@ -48,7 +51,7 @@ void EmuHelper::launch(const Executable * ex, QList micLi fp.append(mic->getFilePath()->getName()); if (!fp.endsWith('/')) fp.append("/"); fp.append(mic->getName()); - int ret = unzipHelper->extractAll(fp, "/tmp/"); + int ret = unzipHelper->extractAll(fp, tmp); if (ret) { qDebug() << "Failed unzipping " << fp << "."; } @@ -68,11 +71,23 @@ void EmuHelper::launch(const Executable * ex, QList micLi cmdWithParams.append(" ").append(opts); qDebug() << "Command with params " << cmdWithParams; - // Executable and MediaImageContainer / MediaImage objects are no more needed: + start(cmdWithParams, QIODevice::ReadOnly); + + // for the moment, we'll wait for the process to be finished until we continue + waitForFinished(-1); + + // clean the temp dir + foreach(EmuFrontObject *ob, miList) { + QString fp = tmp; + fp.append(ob->getName()); + QFile f(fp); + if (!f.remove()) + qDebug() << "Removing " << fp << " failed."; + } delete ex; qDeleteAll(micList); //qDeleteAll(miList); these objects are already deleted along with micList - start(cmdWithParams, QIODevice::ReadOnly); + } void EmuHelper::processError(QProcess::ProcessError) -- 1.7.9.5