Ref T118, utility functions support multiple directories

This commit is contained in:
Klaus Basan
2017-10-20 00:18:20 +02:00
parent 66624e064d
commit 14c912e2aa
4 changed files with 26 additions and 0 deletions

View File

@@ -358,6 +358,16 @@ namespace BlackMisc
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> sl;

View File

@@ -115,6 +115,9 @@ namespace BlackMisc
//! Exists directory and does it contains files
static bool existsUnemptyDirectory(const QString &testDir);
//! Get the existing directories
static QStringList getExistingUnemptyDirectories(const QStringList &directories);
//! Result of directory comparison
struct DirComparison
{

View File

@@ -367,6 +367,16 @@ namespace BlackMisc
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)
{
// from https://stackoverflow.com/a/30958189/356726

View File

@@ -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
static QString fixWindowsUncPath(const QString &filePath);
//! Fix UNC file paths
static QStringList fixWindowsUncPaths(const QStringList &filePaths);
//! Human readable (GB, MB, ..) file size
static QString humanReadableFileSize(qint64 size);
};