* @brief Copies a directory and it's contents from src to dest */
| 481 | * @brief Copies a directory and it's contents from src to dest |
| 482 | */ |
| 483 | class clone : public QObject { |
| 484 | Q_OBJECT |
| 485 | public: |
| 486 | clone(const QString& src, const QString& dst, QObject* parent = nullptr) : QObject(parent) |
| 487 | { |
| 488 | m_src.setPath(src); |
| 489 | m_dst.setPath(dst); |
| 490 | } |
| 491 | clone& matcher(const IPathMatcher* filter) |
| 492 | { |
| 493 | m_matcher = filter; |
| 494 | return *this; |
| 495 | } |
| 496 | clone& whitelist(bool whitelist) |
| 497 | { |
| 498 | m_whitelist = whitelist; |
| 499 | return *this; |
| 500 | } |
| 501 | |
| 502 | bool operator()(bool dryRun = false) { return operator()(QString(), dryRun); } |
| 503 | |
| 504 | qsizetype totalCloned() { return m_cloned; } |
| 505 | qsizetype totalFailed() { return m_failedClones.length(); } |
| 506 | |
| 507 | QList<QPair<QString, QString>> failed() { return m_failedClones; } |
| 508 | |
| 509 | signals: |
| 510 | void fileCloned(const QString& src, const QString& dst); |
| 511 | void cloneFailed(const QString& src, const QString& dst); |
| 512 | |
| 513 | private: |
| 514 | bool operator()(const QString& offset, bool dryRun = false); |
| 515 | |
| 516 | private: |
| 517 | const IPathMatcher* m_matcher = nullptr; |
| 518 | bool m_whitelist = false; |
| 519 | QDir m_src; |
| 520 | QDir m_dst; |
| 521 | qsizetype m_cloned; |
| 522 | QList<QPair<QString, QString>> m_failedClones; |
| 523 | }; |
| 524 | |
| 525 | /** |
| 526 | * @brief clone/reflink file from src to dst |