1 | // Copyright (C) 2024 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #include "qfileutil_p.h" |
5 | #include <QtCore/qfile.h> |
6 | #include <QtCore/qdiriterator.h> |
7 | #include <QtCore/qfileinfo.h> |
8 | #include <QtCore/qstring.h> |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | bool copyAllFiles(const QDir &source, const QDir &dest) |
13 | { |
14 | using namespace Qt::Literals; |
15 | |
16 | if (!source.exists() || !dest.exists()) |
17 | return false; |
18 | |
19 | QDirIterator it(source); |
20 | while (it.hasNext()) { |
21 | QFileInfo file{ it.next() }; |
22 | if (file.isFile()) { |
23 | const QString destination = dest.absolutePath() + u"/"_s+ file.fileName(); |
24 | QFile::copy(fileName: file.absoluteFilePath(), newName: destination); |
25 | } |
26 | } |
27 | |
28 | return true; |
29 | } |
30 | |
31 | QT_END_NAMESPACE |
32 |
Definitions
Learn Advanced QML with KDAB
Find out more