Ensure pathtoUNC is called with an absolute path

This commit is contained in:
Hannah von Reth 2021-01-05 17:43:31 +01:00 committed by Matthieu Gallien (Rebase PR Action)
parent 9ea8dd95f8
commit d014293f6d

View file

@ -18,6 +18,7 @@
#include "filesystembase.h"
#include "utility.h"
#include "common/asserts.h"
#include <QDateTime>
#include <QDir>
@ -509,6 +510,7 @@ bool FileSystem::isJunction(const QString &filename)
#ifdef Q_OS_WIN
QString FileSystem::pathtoUNC(const QString &_str)
{
ASSERT(QFileInfo(_str).isAbsolute());
if (_str.isEmpty()) {
return _str;
}
@ -522,6 +524,7 @@ QString FileSystem::pathtoUNC(const QString &_str)
// prepend \\?\ and to support long names
if (str.at(0) == sep) {
// should not happen as we require the path to be absolute
return QStringLiteral(R"(\\?)") + str;
}
return QStringLiteral(R"(\\?\)") + str;