Fixed issue #702. Valentina produces broken shortcut (.lnk) files on Windows.
(grafted from 1dd5ef5924bf7d78c5c3eeae884e7f4e41bb688d) --HG-- branch : develop
This commit is contained in:
parent
d37618ba08
commit
9be7403919
|
@ -16,6 +16,7 @@
|
|||
- [#696] Wrong grainline position on layout.
|
||||
- [#697] Incomplete Internal Path for Waist Dart.
|
||||
- [#698] Problem typing in new axis point for new piece.
|
||||
- [#702] Valentina produces broken shortcut (.lnk) files on Windows.
|
||||
|
||||
# Version 0.5.0 May 9, 2017
|
||||
- [#581] User can now filter input lists by keyword in function wizard.
|
||||
|
|
|
@ -89,7 +89,7 @@ const QString VCommonSettings::unixStandardSharePath = QStringLiteral("/usr/shar
|
|||
namespace
|
||||
{
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool SymlinkCopyDirRecursive(const QString &fromDir, const QString &toDir, bool replaceOnConflit)
|
||||
void SymlinkCopyDirRecursive(const QString &fromDir, const QString &toDir, bool replaceOnConflit)
|
||||
{
|
||||
QDir dir;
|
||||
dir.setPath(fromDir);
|
||||
|
@ -97,16 +97,39 @@ bool SymlinkCopyDirRecursive(const QString &fromDir, const QString &toDir, bool
|
|||
foreach (QString copyFile, dir.entryList(QDir::Files))
|
||||
{
|
||||
const QString from = fromDir + QDir::separator() + copyFile;
|
||||
const QString to = toDir + QDir::separator() + copyFile;
|
||||
QString to = toDir + QDir::separator() + copyFile;
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
{
|
||||
// To fix issue #702 check each not symlink if it is actually broken symlink.
|
||||
// Also trying to mimic Unix symlink. If a file eaxists do not create a symlink and remove it if exists.
|
||||
QFile fileTo(to);
|
||||
if (fileTo.exists())
|
||||
{
|
||||
if (not fileTo.rename(to + QLatin1String(".lnk")))
|
||||
{
|
||||
QFile::remove(to + QLatin1String(".lnk"));
|
||||
fileTo.rename(to + QLatin1String(".lnk"));
|
||||
}
|
||||
|
||||
QFileInfo info(to + QLatin1String(".lnk"));
|
||||
if (info.symLinkTarget().isEmpty())
|
||||
{
|
||||
fileTo.copy(to);
|
||||
fileTo.remove();
|
||||
continue; // The file already exists, skip creating shortcut
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
to = to + QLatin1String(".lnk");
|
||||
#endif
|
||||
|
||||
if (QFile::exists(to))
|
||||
{
|
||||
if (replaceOnConflit)
|
||||
{
|
||||
if (QFile::remove(to) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
QFile::remove(to);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -114,10 +137,7 @@ bool SymlinkCopyDirRecursive(const QString &fromDir, const QString &toDir, bool
|
|||
}
|
||||
}
|
||||
|
||||
if (QFile::link(from, to) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
QFile::link(from, to);
|
||||
}
|
||||
|
||||
foreach (QString copyDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
|
||||
|
@ -127,16 +147,11 @@ bool SymlinkCopyDirRecursive(const QString &fromDir, const QString &toDir, bool
|
|||
|
||||
if (dir.mkpath(to) == false)
|
||||
{
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (SymlinkCopyDirRecursive(from, to, replaceOnConflit) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
SymlinkCopyDirRecursive(from, to, replaceOnConflit);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,7 +222,7 @@ void VCommonSettings::PrepareStandardTemplates(const QString & currentPath)
|
|||
{
|
||||
QDir standardPath(VCommonSettings::StandardTemplatesPath());
|
||||
const QDir localdata (VCommonSettings::GetDefPathTemplate());
|
||||
if (currentPath == VCommonSettings::GetDefPathTemplate() && standardPath.exists() && not localdata.exists())
|
||||
if (currentPath == VCommonSettings::GetDefPathTemplate() && standardPath.exists())
|
||||
{
|
||||
if (localdata.mkpath("."))
|
||||
{
|
||||
|
@ -222,9 +237,7 @@ void VCommonSettings::PrepareStandardTables(const QString ¤tPath)
|
|||
{
|
||||
QDir standardPath(VCommonSettings::StandardTablesPath());
|
||||
const QDir localdata (VCommonSettings::GetDefPathStandardMeasurements());
|
||||
if (currentPath == VCommonSettings::GetDefPathStandardMeasurements()
|
||||
&& standardPath.exists()
|
||||
&& not localdata.exists())
|
||||
if (currentPath == VCommonSettings::GetDefPathStandardMeasurements() && standardPath.exists())
|
||||
{
|
||||
if (localdata.mkpath("."))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user