16 if (!source.exists() || !dest.exists())
19 QDirIterator it(source, QDirIterator::Subdirectories);
21 while (it.hasNext()) {
22 QFileInfo file{ it.next() };
23 const QString relativePath = source.relativeFilePath(file.absoluteFilePath());
24 const QString destination = dest.absolutePath() + u"/"_s + relativePath;
27 if (QFile::exists(destination))
28 if (!QFile::remove(destination))
31 if (!QFile::copy(file.absoluteFilePath(), destination))
34 }
else if (file.isDir()) {
35 if (!QDir(destination).exists())
36 if (!dest.mkpath(relativePath))
45 const QString &fileTemplate)
48 if (resource.scheme() ==
"qrc"_L1)
49 resourcePath = u':' + resource.path();
50 else if (resource.isLocalFile())
51 resourcePath = resource.toLocalFile();
55 QFile resourceFile(resourcePath);
56 if (!resourceFile.open(QIODeviceBase::ReadOnly))
59 auto temporaryFile = std::make_unique<QTemporaryFile>(fileTemplate);
60 if (!temporaryFile->open())
63 if (temporaryFile->write(resourceFile.readAll()) < 0)
66 temporaryFile->close();