45 changes: 15 additions & 30 deletions libk3b/projects/videodvd/k3bvideodvdimager.cpp
Original file line number Diff line number Diff line change
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 );
}


4 changes: 3 additions & 1 deletion libk3b/projects/videodvd/k3bvideodvdimager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include "k3bisoimager.h"

#include <QtCore/QScopedPointer>

namespace K3b {
class VideoDvdDoc;

Expand Down Expand Up @@ -54,7 +56,7 @@ namespace K3b {
void fixVideoDVDSettings();

class Private;
Private* d;
QScopedPointer<Private> d;
};
}

Expand Down
1 change: 0 additions & 1 deletion src/rip/k3bvideocdrip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <KI18n/KLocalizedString>
#include <KCoreAddons/KProcess>
#include <KDELibs4Support/KDE/KStandardDirs>
#include <KTemporaryFile>
#include <QtCore/QUrl>

#include <QtCore/QDateTime>
Expand Down