Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 76f6952f rédigé par Kubat's avatar Kubat
Parcourir les fichiers

LIB: Fix the renameWith and copyWith functions

parent e4ae4fbe
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!18Implement the VivyDocument specification
...@@ -43,9 +43,19 @@ protected: ...@@ -43,9 +43,19 @@ protected:
dirOp.mkpath(newAbsDirPath); dirOp.mkpath(newAbsDirPath);
} }
if (QFile::copy(oldFile.absoluteFilePath(), newFile.absoluteFilePath())) if (newFile.exists()) {
return success(); qWarning() << "Deleting the already existing" << newFile;
if (!dirOp.remove(newFile.absoluteFilePath()))
throw std::runtime_error("Failed to remove " +
newFile.absoluteFilePath().toStdString());
}
if (QFile::copy(oldFile.absoluteFilePath(), newFile.absoluteFilePath())) {
success();
save();
}
else
throw std::runtime_error("Failed to copy " + oldFile.absoluteFilePath().toStdString() + throw std::runtime_error("Failed to copy " + oldFile.absoluteFilePath().toStdString() +
" to " + newFile.absoluteFilePath().toStdString()); " to " + newFile.absoluteFilePath().toStdString());
} }
...@@ -64,11 +74,23 @@ protected: ...@@ -64,11 +74,23 @@ protected:
dirOp.mkpath(newAbsDirPath); dirOp.mkpath(newAbsDirPath);
} }
if (dirOp.rename(oldFile.absoluteFilePath(), newFile.absoluteFilePath())) if (newFile.exists()) {
return success(); qWarning() << "Deleting the already existing" << newFile;
dirOp.remove(newFile.absoluteFilePath());
if (!dirOp.remove(newFile.absoluteFilePath()))
throw std::runtime_error("Failed to remove " +
newFile.absoluteFilePath().toStdString());
}
throw std::runtime_error("Failed to rename " + oldFile.absoluteFilePath().toStdString() + if (dirOp.rename(oldFile.absoluteFilePath(), newFile.absoluteFilePath())) {
" to " + newFile.absoluteFilePath().toStdString()); success();
save();
}
else
throw std::runtime_error("Failed to rename " +
oldFile.absoluteFilePath().toStdString() + " to " +
newFile.absoluteFilePath().toStdString());
} }
Type type; Type type;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter