added special case for windows
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
5afe6600ee
commit
1d67fc6646
@ -643,6 +643,19 @@ void ExternalLinkFileProcess::runLinkFile()
|
||||
qDebug() << "Process exited";
|
||||
}
|
||||
|
||||
bool moveByCopy(const QString& source, const QString& dest)
|
||||
{
|
||||
if (!copy(source, dest)()) { // copy
|
||||
qDebug() << "Copy of" << source << "to" << dest << "failed!";
|
||||
return false;
|
||||
}
|
||||
if (!deletePath(source)) { // remove original
|
||||
qDebug() << "Deletion of" << source << "failed!";
|
||||
return false;
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
bool move(const QString& source, const QString& dest)
|
||||
{
|
||||
std::error_code err;
|
||||
@ -650,12 +663,14 @@ bool move(const QString& source, const QString& dest)
|
||||
ensureFilePathExists(dest);
|
||||
fs::rename(StringUtils::toStdString(source), StringUtils::toStdString(dest), err);
|
||||
|
||||
if (err) {
|
||||
qWarning() << "Failed to move file:" << QString::fromStdString(err.message());
|
||||
qDebug() << "Source file:" << source << ";Destination file:" << dest;
|
||||
if (err.value() != 0) {
|
||||
if (moveByCopy(source, dest))
|
||||
return true;
|
||||
qDebug() << "Move of" << source << "to" << dest << "failed!";
|
||||
qWarning() << "Failed to move file:" << QString::fromStdString(err.message()) << QString::number(err.value());
|
||||
return false;
|
||||
}
|
||||
|
||||
return err.value() == 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool deletePath(QString path)
|
||||
|
Loading…
Reference in New Issue
Block a user