mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-23 05:45:35 +08:00
Ref T118, utility functions support multiple directories
This commit is contained in:
@@ -358,6 +358,16 @@ namespace BlackMisc
|
|||||||
return !dir.isEmpty();
|
return !dir.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList CDirectoryUtils::getExistingUnemptyDirectories(const QStringList &directories)
|
||||||
|
{
|
||||||
|
QStringList dirs;
|
||||||
|
for (const QString &dir : directories)
|
||||||
|
{
|
||||||
|
if (existsUnemptyDirectory(dir)) { dirs << dir; }
|
||||||
|
}
|
||||||
|
return dirs;
|
||||||
|
}
|
||||||
|
|
||||||
QSet<QString> CDirectoryUtils::fileNamesToQSet(const QFileInfoList &fileInfoList)
|
QSet<QString> CDirectoryUtils::fileNamesToQSet(const QFileInfoList &fileInfoList)
|
||||||
{
|
{
|
||||||
QSet<QString> sl;
|
QSet<QString> sl;
|
||||||
|
|||||||
@@ -115,6 +115,9 @@ namespace BlackMisc
|
|||||||
//! Exists directory and does it contains files
|
//! Exists directory and does it contains files
|
||||||
static bool existsUnemptyDirectory(const QString &testDir);
|
static bool existsUnemptyDirectory(const QString &testDir);
|
||||||
|
|
||||||
|
//! Get the existing directories
|
||||||
|
static QStringList getExistingUnemptyDirectories(const QStringList &directories);
|
||||||
|
|
||||||
//! Result of directory comparison
|
//! Result of directory comparison
|
||||||
struct DirComparison
|
struct DirComparison
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -367,6 +367,16 @@ namespace BlackMisc
|
|||||||
return f.arg(filePath);
|
return f.arg(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList CFileUtils::fixWindowsUncPaths(const QStringList &filePaths)
|
||||||
|
{
|
||||||
|
QStringList fixedPaths;
|
||||||
|
for (const QString &path : filePaths)
|
||||||
|
{
|
||||||
|
fixedPaths << fixWindowsUncPath(path);
|
||||||
|
}
|
||||||
|
return fixedPaths;
|
||||||
|
}
|
||||||
|
|
||||||
QString CFileUtils::humanReadableFileSize(qint64 size)
|
QString CFileUtils::humanReadableFileSize(qint64 size)
|
||||||
{
|
{
|
||||||
// from https://stackoverflow.com/a/30958189/356726
|
// from https://stackoverflow.com/a/30958189/356726
|
||||||
|
|||||||
@@ -134,6 +134,9 @@ namespace BlackMisc
|
|||||||
//! \remark On Windows starting with "/" means an UNC path, on UNIX it varies, see http://unix.stackexchange.com/a/12291/19428
|
//! \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);
|
static QString fixWindowsUncPath(const QString &filePath);
|
||||||
|
|
||||||
|
//! Fix UNC file paths
|
||||||
|
static QStringList fixWindowsUncPaths(const QStringList &filePaths);
|
||||||
|
|
||||||
//! Human readable (GB, MB, ..) file size
|
//! Human readable (GB, MB, ..) file size
|
||||||
static QString humanReadableFileSize(qint64 size);
|
static QString humanReadableFileSize(qint64 size);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user