mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 18:25:37 +08:00
Ref T620, check for empty string as path, QDir("") exists
This commit is contained in:
@@ -96,6 +96,7 @@ namespace BlackMisc
|
||||
|
||||
QString CDirectories::existingOrDefaultDir(const QString &checkDir, const QString &defaultDir) const
|
||||
{
|
||||
if (checkDir.isEmpty()) { return defaultDir; } // empty dir returns true ????
|
||||
const QDir d(checkDir);
|
||||
if (d.exists()) { return checkDir; }
|
||||
return defaultDir;
|
||||
|
||||
@@ -39,6 +39,12 @@ namespace BlackMisc
|
||||
return binDir;
|
||||
}
|
||||
|
||||
bool CDirectoryUtils::isInApplicationDirectory(const QString &path)
|
||||
{
|
||||
if (path.isEmpty()) { return false; }
|
||||
return path.contains(qApp->applicationDirPath(), CFileUtils::osFileNameCaseSensitivity());
|
||||
}
|
||||
|
||||
const QString &CDirectoryUtils::pluginsDirectory()
|
||||
{
|
||||
static const QString pDir(CFileUtils::appendFilePaths(binDirectory(), "plugins"));
|
||||
@@ -386,7 +392,7 @@ namespace BlackMisc
|
||||
{
|
||||
const QStringList pathes(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation));
|
||||
QString d = pathes.first();
|
||||
d = QDir::cleanPath(d + QDir::separator() + "swift");
|
||||
d = QDir::cleanPath(CFileUtils::appendFilePaths(d, "swift"));
|
||||
QDir dir(d);
|
||||
if (dir.exists()) { return dir.absolutePath(); }
|
||||
return pathes.first();
|
||||
|
||||
@@ -37,6 +37,9 @@ namespace BlackMisc
|
||||
//! \see https://dev.swift-project.org/w/dev/swiftpc/dirstructure/
|
||||
static const QString &binDirectory();
|
||||
|
||||
//! Path in application directory
|
||||
static bool isInApplicationDirectory(const QString &path);
|
||||
|
||||
//! Plugins directory
|
||||
static const QString &pluginsDirectory();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user