mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Renamed function id Directory utils and added string only version
This commit is contained in:
committed by
Mat Sutcliffe
parent
cd63712cd7
commit
cb77279b4d
@@ -543,19 +543,19 @@ namespace BlackMisc
|
||||
return d1.absolutePath() == d2.absolutePath();
|
||||
}
|
||||
|
||||
bool CDirectoryUtils::isSubDirectoryOf(const QString &dir1, const QString &dir2)
|
||||
bool CDirectoryUtils::isSameOrSubDirectoryOf(const QString &testDir, const QString &dir2)
|
||||
{
|
||||
if (dir1.isEmpty() || dir2.isEmpty()) { return false; }
|
||||
if (testDir.isEmpty() || dir2.isEmpty()) { return false; }
|
||||
const QDir d2(dir2);
|
||||
return CDirectoryUtils::isSubDirectoryOf(dir1, d2);
|
||||
return CDirectoryUtils::isSameOrSubDirectoryOf(testDir, d2);
|
||||
}
|
||||
|
||||
bool CDirectoryUtils::isSubDirectoryOf(const QString &dir1, const QDir &dir2)
|
||||
bool CDirectoryUtils::isSameOrSubDirectoryOf(const QString &dir1, const QDir &parentDir)
|
||||
{
|
||||
QDir d1(dir1);
|
||||
do
|
||||
{
|
||||
if (d1 == dir2) { return true; }
|
||||
if (d1 == parentDir) { return true; }
|
||||
}
|
||||
while (d1.cdUp());
|
||||
|
||||
@@ -563,6 +563,14 @@ namespace BlackMisc
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CDirectoryUtils::isSameOrSubDirectoryOfStringBased(const QString &testDir, const QString &parentDir)
|
||||
{
|
||||
const Qt::CaseSensitivity cs = CFileUtils::osFileNameCaseSensitivity();
|
||||
const QString td = CFileUtils::fixWindowsUncPath(QDir::cleanPath(testDir));
|
||||
const QString pd = CFileUtils::fixWindowsUncPath(QDir::cleanPath(parentDir));
|
||||
return td.contains(pd, cs);
|
||||
}
|
||||
|
||||
QSet<QString> CDirectoryUtils::fileNamesToQSet(const QFileInfoList &fileInfoList)
|
||||
{
|
||||
QSet<QString> sl;
|
||||
|
||||
@@ -187,13 +187,17 @@ namespace BlackMisc
|
||||
//! Same existing directories
|
||||
static bool isSameExistingDirectory(const QString &dir1, const QString &dir2);
|
||||
|
||||
//! Is dir1 a subdirectory (possibly nested) of dir2 or the same directory
|
||||
//! Is "testDir" a subdirectory (possibly nested) of "parentDir" or the same directory
|
||||
//! \remark testing on real directory structure
|
||||
static bool isSubDirectoryOf(const QString &dir1, const QString &dir2);
|
||||
static bool isSameOrSubDirectoryOf(const QString &testDir, const QString &parentDir);
|
||||
|
||||
//! Is dir1 a subdirectory (possibly nested) of dir2 or the same directory
|
||||
//! Is "testDir" a subdirectory (possibly nested) of "parentDir" or the same directory
|
||||
//! \remark testing on real directory structure
|
||||
static bool isSubDirectoryOf(const QString &dir1, const QDir &dir2);
|
||||
static bool isSameOrSubDirectoryOf(const QString &testDir, const QDir &parentDir);
|
||||
|
||||
//! Is "testDir" a subdirectory (possibly nested) of "parentDir" or the same directory
|
||||
//! \remark String based only
|
||||
static bool isSameOrSubDirectoryOfStringBased(const QString &testDir, const QString &parentDir);
|
||||
|
||||
//! Result of directory comparison
|
||||
struct DirComparison
|
||||
|
||||
@@ -576,7 +576,7 @@ namespace BlackSimPlugin
|
||||
{
|
||||
Q_ASSERT(package.s.endsWith('/'));
|
||||
package.s.chop(1);
|
||||
if (CDirectoryUtils::isSubDirectoryOf(package.s, simDir))
|
||||
if (CDirectoryUtils::isSameOrSubDirectoryOf(package.s, simDir))
|
||||
{
|
||||
m_trafficProxy->loadPlanesPackage(package.s);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user