Ref T258, utility functions

This commit is contained in:
Klaus Basan
2018-02-22 00:57:30 +01:00
parent b5a32f3c5d
commit 68d4243ca7
4 changed files with 20 additions and 0 deletions

View File

@@ -406,6 +406,12 @@ namespace BlackMisc
return fixedPaths;
}
QString CFileUtils::toWindowsLocalPath(const QString &path)
{
QString p = CFileUtils::fixWindowsUncPath(path);
return p.replace('/', '\\');
}
QString CFileUtils::humanReadableFileSize(qint64 size)
{
// from https://stackoverflow.com/a/30958189/356726

View File

@@ -151,6 +151,9 @@ namespace BlackMisc
//! Fix UNC file paths
static QStringList fixWindowsUncPaths(const QStringList &filePaths);
//! To Windows path using "\" delimiter
static QString toWindowsLocalPath(const QString &path);
//! Human readable (GB, MB, ..) file size
static QString humanReadableFileSize(qint64 size);

View File

@@ -331,6 +331,14 @@ namespace BlackMisc
if (in.isEmpty()) { return ignoreEmpty ? e : ea; }
return QStringLiteral("'") % in % QStringLiteral("'");
}
const QString inQuotes(const QString &in, bool ignoreEmpty)
{
static const QString e;
static const QString ea("\"\"");
if (in.isEmpty()) { return ignoreEmpty ? e : ea; }
return QStringLiteral("\"") % in % QStringLiteral("\"");
}
}
//! \endcond

View File

@@ -123,6 +123,9 @@ namespace BlackMisc
//! Return string in apostrophes
BLACKMISC_EXPORT const QString inApostrophes(const QString &in, bool ignoreEmpty = false);
//! Return string in quotes
BLACKMISC_EXPORT const QString inQuotes(const QString &in, bool ignoreEmpty = false);
//! Bool to on/off
BLACKMISC_EXPORT const QString &boolToOnOff(bool v);