refs #911, support for Windows UNC paths in parser

This commit is contained in:
Klaus Basan
2017-03-22 03:10:41 +01:00
committed by Mathew Sutcliffe
parent b0fe4ce930
commit 6d97f477c9
3 changed files with 16 additions and 2 deletions

View File

@@ -346,4 +346,12 @@ namespace BlackMisc
default: return QStringLiteral("Bad error number");
}
}
QString CFileUtils::fixWindowsUncPath(const QString &filePath)
{
if (!filePath.startsWith('/')) { return filePath; }
if (filePath.startsWith("//")) { return filePath; }
static const QString f("/%1");
return f.arg(filePath);
}
} // ns

View File

@@ -126,6 +126,10 @@ namespace BlackMisc
//! Error message explaining why a QLockFile failed to lock.
static QString lockFileError(const QLockFile &lockFile);
//! UNC file paths on Qt start with "/", but UNC file paths only work when they start with "//"
//! \remark On Windows starting with "/" means an UNC path, on UNIX it varies, see http://unix.stackexchange.com/a/12291/19428
static QString fixWindowsUncPath(const QString &filePath);
};
} // ns

View File

@@ -69,7 +69,9 @@ namespace BlackMisc
static const CStatusMessage statusLoadingError(this, CStatusMessage::SeverityError, "Aircraft config parser did not load data");
const CSimulatorInfo simulator = this->getSimulator();
const QString modelDirectory(!directory.isEmpty() ? directory : this->m_settings.getFirstModelDirectoryOrDefault(simulator)); // expect only one directory
const QString modelDirectory = CFileUtils::fixWindowsUncPath(
directory.isEmpty() ? this->m_settings.getFirstModelDirectoryOrDefault(simulator) : directory
); // expect only one directory
const QStringList excludedDirectoryPatterns(this->m_settings.getModelExcludeDirectoryPatternsOrDefault(simulator)); // copy
if (mode.testFlag(LoadInBackground))
@@ -170,7 +172,7 @@ namespace BlackMisc
return CAircraftCfgEntriesList(); // can happen if there are shortcuts or linked dirs not available
}
QString currentDir = dir.absolutePath();
const QString currentDir = dir.absolutePath();
CAircraftCfgEntriesList result;
// Dirs last is crucial,since I will break recursion on "aircraft.cfg" level