Skip to content

Commit 4f2a1c1

Browse files
committed
Fixed Target-directory not correctly build when exporting effects
1 parent 9a450a9 commit 4f2a1c1

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7474
- Fixed Removed stale _logger object
7575
- Fixed Smoothing (#1863)
7676
- Fixed Crash when XCB,X11 was configured and display manager changed to Wayland
77+
- Fixed Target-directory not correctly build when exporting effects
7778

7879
**JSON-API**
7980
- Refactored JSON-API to ensure consistent authorization behaviour across sessions and single requests with token authorization.

src/hyperiond/main.cpp

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -235,30 +235,49 @@ int main(int argc, char** argv)
235235
if (parser.isSet(exportEfxOption))
236236
{
237237
Q_INIT_RESOURCE(EffectEngine);
238-
QDir directory(":/effects/");
239-
QDir destDir(exportEfxOption.value(parser));
240-
if (directory.exists() && destDir.exists())
238+
QDir const sourceDir(":/effects/");
239+
QDir const destinationDir(exportEfxOption.value(parser));
240+
241+
// Create destination if it does not exist
242+
if (!destinationDir.exists())
243+
{
244+
std::cout << "Creating target directory: " << destinationDir.absolutePath().toStdString() << '\n';
245+
if (!QDir().mkpath(destinationDir.absolutePath()))
246+
{
247+
std::cerr << "Failed to create directory: \"" << destinationDir.absolutePath().toStdString() << "\", aborting" << '\n';
248+
return 1;
249+
}
250+
}
251+
252+
if (sourceDir.exists())
241253
{
242-
std::cout << "Extract to folder: " << destDir.absolutePath().toStdString() << std::endl;
243-
const QStringList filenames = directory.entryList(QStringList() << "*", QDir::Files, QDir::Name | QDir::IgnoreCase);
244-
QString destFileName;
254+
std::cout << "Extract to folder: " << destinationDir.absolutePath().toStdString() << '\n';
255+
const QStringList filenames = sourceDir.entryList(QStringList() << "*", QDir::Files, QDir::Name | QDir::IgnoreCase);
245256
for (const QString & filename : filenames)
246257
{
247-
destFileName = destDir.dirName()+"/"+filename;
248-
if (QFile::exists(destFileName))
258+
QString const sourceFilePath = sourceDir.absoluteFilePath(filename);
259+
QString const destinationFilePath = destinationDir.absoluteFilePath(filename);
260+
261+
if (QFile::exists(destinationFilePath))
262+
{
263+
QFile::remove(destinationFilePath);
264+
}
265+
266+
if (Logger::getLogLevel() == Logger::DEBUG )
249267
{
250-
QFile::remove(destFileName);
268+
std::cout << "Copy \"" << sourceFilePath.toStdString() << "\" -> \"" << destinationFilePath.toStdString() << "\"" << '\n';
251269
}
252270

253271
std::cout << "Extract: " << filename.toStdString() << " ... ";
254-
if (QFile::copy(QString(":/effects/")+filename, destFileName))
272+
if (QFile::copy(sourceFilePath, destinationFilePath))
255273
{
256-
QFile::setPermissions(destFileName, PERM0664 );
257-
std::cout << "OK" << std::endl;
274+
QFile::setPermissions(destinationFilePath, PERM0664 );
275+
std::cout << "OK" << '\n';
258276
}
259277
else
260278
{
261-
std::cout << "Error, aborting" << std::endl;
279+
std::cerr << "Error copying [" << sourceFilePath.toStdString() << " -> [" << destinationFilePath.toStdString() << "]" << '\n';
280+
std::cerr << "Error, aborting" << '\n';
262281
return 1;
263282
}
264283
}

0 commit comments

Comments
 (0)