mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
Ref T203, file utility functions
This commit is contained in:
@@ -216,10 +216,7 @@ namespace BlackMisc
|
||||
if (excludeDirectories.isEmpty()) { return false; }
|
||||
for (const QString &ex : excludeDirectories)
|
||||
{
|
||||
if (matchesExcludeDirectory(directoryPath, ex, cs))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (matchesExcludeDirectory(directoryPath, ex, cs)) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -394,4 +391,26 @@ namespace BlackMisc
|
||||
}
|
||||
return QString("%1 %2").arg(CMathUtils::roundAsString(currentSize, 2), unit);
|
||||
}
|
||||
|
||||
const QStringList &CFileUtils::executableSuffixes()
|
||||
{
|
||||
// incomplete list of file name appendixes
|
||||
static const QStringList appendixes({".exe", ".dmg", ".run"});
|
||||
return appendixes;
|
||||
}
|
||||
|
||||
bool CFileUtils::isExecutableFile(const QString &fileName)
|
||||
{
|
||||
for (const QString &app : CFileUtils::executableSuffixes())
|
||||
{
|
||||
if (fileName.endsWith(app, Qt::CaseInsensitive)) { return true; }
|
||||
}
|
||||
return CFileUtils::isSwiftInstaller(fileName);
|
||||
}
|
||||
|
||||
bool CFileUtils::isSwiftInstaller(const QString &fileName)
|
||||
{
|
||||
if (fileName.isEmpty()) { return false; }
|
||||
return fileName.contains("swift", Qt::CaseInsensitive) && fileName.contains("installer");
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -139,6 +139,15 @@ namespace BlackMisc
|
||||
|
||||
//! Human readable (GB, MB, ..) file size
|
||||
static QString humanReadableFileSize(qint64 size);
|
||||
|
||||
//! Executable file name appendixes
|
||||
static const QStringList &executableSuffixes();
|
||||
|
||||
//! Executable file (decided by appendix)
|
||||
static bool isExecutableFile(const QString &fileName);
|
||||
|
||||
//! swift installer
|
||||
static bool isSwiftInstaller(const QString &fileName);
|
||||
};
|
||||
} // ns
|
||||
|
||||
|
||||
Reference in New Issue
Block a user