Check UNC path to avoid "hanging" if other machine is not reachable

This commit is contained in:
Klaus Basan
2020-04-14 02:44:02 +02:00
committed by Mat Sutcliffe
parent 04562a6651
commit e839820940
4 changed files with 93 additions and 2 deletions

View File

@@ -506,6 +506,31 @@ namespace BlackMisc
return f.left(i);
}
QSet<QString> CFileUtils::windowsUncMachines(const QSet<QString> &paths)
{
if (paths.isEmpty()) { return {}; }
const Qt::CaseSensitivity cs = osFileNameCaseSensitivity();
const bool isCs = isFileNameCaseSensitive();
QSet<QString> machines;
QString lastMachine;
for (const QString &p : paths)
{
if (!lastMachine.isEmpty() && p.contains(lastMachine, cs))
{
// shortcut
continue;
}
const QString m = isCs ? windowsUncMachine(p) : windowsUncMachine(p).toLower();
if (m.isEmpty()) { continue; }
lastMachine = m;
machines.insert(m);
}
return machines;
}
bool CFileUtils::canPingUncMachine(const QString &machine)
{
static QMap<QString, qint64> good;