From d2679715487c2254ed5a55b20aa21ea0b36421f0 Mon Sep 17 00:00:00 2001 From: Leslie Zhai Date: Fri, 11 Aug 2017 09:17:15 +0800 Subject: Fix cannot create DVD video image issue. BUG: 383011 Reviewers: aacid, anthonyfieroni, sitter Reviewed By: sitter Subscribers: KDE Applications Differential Revision: https://phabricator.kde.org/D7063 --- libk3b/projects/videodvd/k3bvideodvdimager.cpp | 35 +++++++++++++++----------- 1 file changed, 21 insertions(+), 14 deletions(-) Index: k3b-17.08.2/libk3b/projects/videodvd/k3bvideodvdimager.cpp =================================================================== --- k3b-17.08.2.orig/libk3b/projects/videodvd/k3bvideodvdimager.cpp +++ k3b-17.08.2/libk3b/projects/videodvd/k3bvideodvdimager.cpp @@ -101,30 +101,37 @@ int K3b::VideoDvdImager::writePathSpec() // // We do this here since K3b::IsoImager::start calls cleanup which deletes the temp files // - 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 ); + d->tempDir.reset(new QTemporaryDir(QDir::tempPath() + "/k3bVideoDvdXXXXXX")); + if (!d->tempDir->isValid()) { + emit infoMessage(xi18n("Unable to create Invalid temporary folder %1.", + d->tempDir->path()), MessageError); return -1; } - dir.cd( dir.path() ); - if( !dir.mkdir( "VIDEO_TS" ) ) { - emit infoMessage( i18n("Unable to create temporary folder '%1'.",dir.path() + "/VIDEO_TS"), MessageError ); + const auto videoDir = +#if QT_VERSION < 0x050900 + d->tempDir->path() + "/VIDEO_TS"; +#else + d->tempDir->filePath("VIDEO_TS"); +#endif + if (!QDir().mkpath(videoDir)) { + emit infoMessage(xi18n("Unable to create temporary folder %1.", + videoDir), MessageError); return -1; } - Q_FOREACH( K3b::DataItem* item, d->doc->videoTsDir()->children() ) { - if( item->isDir() ) { - emit infoMessage( i18n("Found invalid entry in the VIDEO_TS folder (%1).",item->k3bName()), MessageError ); + Q_FOREACH(const K3b::DataItem* item, d->doc->videoTsDir()->children()) { + if (item->isDir()) { + emit infoMessage(xi18n("Found invalid entry in the VIDEO_TS folder %1.", + item->k3bName()), MessageError); return -1; } // convert to upper case names - if( ::symlink( QFile::encodeName( item->localPath() ), - QFile::encodeName( dir.path() + "/VIDEO_TS/" + item->k3bName().toUpper() ) ) == -1 ) { - emit infoMessage( i18n("Unable to link temporary file in folder %1.", dir.path() ), MessageError ); + if (::symlink(QFile::encodeName(item->localPath()), + QFile::encodeName(videoDir + "/" + item->k3bName().toUpper())) == -1) { + emit infoMessage(xi18n("Unable to link temporary file in folder %1.", + d->tempDir->path()), MessageError); return -1; } }