From b5d812586733353000e741bd4448f217e8ec1224 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Wed, 27 Aug 2025 17:56:46 +1000 Subject: internal: better copy --- plugin/src/Caelestia/cutils.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'plugin/src/Caelestia/cutils.cpp') diff --git a/plugin/src/Caelestia/cutils.cpp b/plugin/src/Caelestia/cutils.cpp index fd7fcdd..2415f80 100644 --- a/plugin/src/Caelestia/cutils.cpp +++ b/plugin/src/Caelestia/cutils.cpp @@ -68,3 +68,24 @@ void CUtils::saveItem(QQuickItem* target, const QUrl& path, const QRect& rect, Q } ); } + +bool CUtils::copyFile(const QUrl& source, const QUrl& target) const { + return this->copyFile(source, target, true); +} + +bool CUtils::copyFile(const QUrl& source, const QUrl& target, bool overwrite) const { + if (!source.isLocalFile()) { + qWarning() << "CUtils::copyFile: source" << source << "is not a local file"; + return false; + } + if (!target.isLocalFile()) { + qWarning() << "CUtils::copyFile: target" << target << "is not a local file"; + return false; + } + + if (overwrite) { + QFile::remove(target.toLocalFile()); + } + + return QFile::copy(source.toLocalFile(), target.toLocalFile()); +} -- cgit v1.2.3-freya