Expand Up
@@ -20,15 +20,13 @@
#include " k3bglobals.h"
#include " k3bisooptions.h"
#include < KDELibs4Support/KDE/KTemporaryFile>
#include < KDELibs4Support/KDE/KGlobal>
#include < KDELibs4Support/KDE/KStandardDirs>
#include < KI18n/KLocalizedString>
#include < QtCore/QDebug>
#include < QtCore/QDir>
#include < QtCore/QFile>
#include < QtCore/QList>
#include < QtCore/QTemporaryDir>
#include < QtCore/QTextStream>
#include < unistd.h>
Expand All
@@ -39,21 +37,20 @@ class K3b::VideoDvdImager::Private
public:
K3b::VideoDvdDoc* doc;
QString tempPath ;
QScopedPointer<QTemporaryDir> tempDir ;
};
K3b::VideoDvdImager::VideoDvdImager ( K3b::VideoDvdDoc* doc, K3b::JobHandler* jh, QObject* parent )
: K3b::IsoImager( doc, jh, parent )
: K3b::IsoImager( doc, jh, parent ),
d( new Private )
{
d = new Private;
d->doc = doc;
}
K3b::VideoDvdImager::~VideoDvdImager ()
{
delete d;
}
Expand Down
Expand Up
@@ -105,17 +102,17 @@ int K3b::VideoDvdImager::writePathSpec()
//
// We do this here since K3b::IsoImager::start calls cleanup which deletes the temp files
//
QDir dir ( KGlobal::dirs ()-> resourceDirs ( " tmp " ). first ( ) );
d-> tempPath = K3b::findUniqueFilePrefix ( " k3bVideoDvd " , dir. path () );
qDebug () << " (K3b::VideoDvdImager) creating temp dir: " << d-> tempPath ;
if ( !dir.mkdir ( d-> tempPath ) ) {
emit infoMessage ( i18n (" Unable to create temporary folder '%1'." ,d-> tempPath ), MessageError );
d-> tempDir . reset ( new QTemporaryDir ( " k3bVideoDvdXXXXXX " ) );
QDir dir ( d-> tempDir -> path () );
qDebug () << " (K3b::VideoDvdImager) creating temp dir: " << dir. path () ;
if ( !dir.mkdir ( dir. path () ) ) {
emit infoMessage ( i18n (" Unable to create temporary folder '%1'." ,dir. path () ), MessageError );
return -1 ;
}
dir.cd ( d-> tempPath );
dir.cd ( dir. path () );
if ( !dir.mkdir ( " VIDEO_TS" ) ) {
emit infoMessage ( i18n (" Unable to create temporary folder '%1'." ,d-> tempPath + " /VIDEO_TS" ), MessageError );
emit infoMessage ( i18n (" Unable to create temporary folder '%1'." ,dir. path () + " /VIDEO_TS" ), MessageError );
return -1 ;
}
Expand All
@@ -127,8 +124,8 @@ int K3b::VideoDvdImager::writePathSpec()
// convert to upper case names
if ( ::symlink ( QFile::encodeName ( item->localPath () ),
QFile::encodeName ( d-> tempPath + " /VIDEO_TS/" + item->k3bName ().toUpper () ) ) == -1 ) {
emit infoMessage ( i18n (" Unable to link temporary file in folder %1." , d-> tempPath ), MessageError );
QFile::encodeName ( dir. path () + " /VIDEO_TS/" + item->k3bName ().toUpper () ) ) == -1 ) {
emit infoMessage ( i18n (" Unable to link temporary file in folder %1." , dir. path () ), MessageError );
return -1 ;
}
}
Expand Down
Expand Up
@@ -182,7 +179,7 @@ bool K3b::VideoDvdImager::addMkisofsParameters( bool printSize )
if ( K3b::IsoImager::addMkisofsParameters ( printSize ) ) {
*m_process << " -dvd-video" ;
*m_process << " -f" ; // follow symlinks
*m_process << d->tempPath ;
*m_process << ( d->tempDir ? d-> tempDir -> path () : QString ()) ;
return true ;
}
else
Expand All
@@ -192,17 +189,7 @@ bool K3b::VideoDvdImager::addMkisofsParameters( bool printSize )
void K3b::VideoDvdImager::cleanup ()
{
if ( QFile::exists ( d->tempPath ) ) {
QDir dir ( d->tempPath );
dir.cd ( " VIDEO_TS" );
Q_FOREACH ( K3b::DataItem* item, d->doc ->videoTsDir ()->children () )
dir.remove ( item->k3bName ().toUpper () );
dir.cdUp ();
dir.rmdir ( " VIDEO_TS" );
dir.cdUp ();
dir.rmdir ( d->tempPath );
}
d->tempPath = QString ();
d->tempDir .reset ();
K3b::IsoImager::cleanup ();
}
Expand All
@@ -217,5 +204,3 @@ void K3b::VideoDvdImager::slotReceivedStderr( const QString& line )
else
K3b::IsoImager::slotReceivedStderr ( line );
}