Utils: Better error reporting for copyFile

Change-Id: Id76280e83e9dae92bff2db5722f1e582867e1566
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Marcus Tillmanns
2023-03-12 20:26:00 +01:00
parent 8f1cbd2e52
commit e093c39727

View File

@@ -565,10 +565,13 @@ bool DesktopDeviceFileAccess::removeRecursively(const FilePath &filePath, QStrin
expected_str<void> DesktopDeviceFileAccess::copyFile(const FilePath &filePath, expected_str<void> DesktopDeviceFileAccess::copyFile(const FilePath &filePath,
const FilePath &target) const const FilePath &target) const
{ {
if (QFile::copy(filePath.path(), target.path())) QFile srcFile(filePath.path());
if (srcFile.copy(target.path()))
return {}; return {};
return make_unexpected(Tr::tr("Failed to copy file \"%1\" to \"%2\".") return make_unexpected(
.arg(filePath.toUserOutput(), target.toUserOutput())); Tr::tr("Failed to copy file \"%1\" to \"%2\": %3")
.arg(filePath.toUserOutput(), target.toUserOutput(), srcFile.errorString()));
} }
bool DesktopDeviceFileAccess::renameFile(const FilePath &filePath, const FilePath &target) const bool DesktopDeviceFileAccess::renameFile(const FilePath &filePath, const FilePath &target) const