mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 04:25:42 +08:00
Ref T258, utility functions
This commit is contained in:
@@ -406,6 +406,12 @@ namespace BlackMisc
|
|||||||
return fixedPaths;
|
return fixedPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CFileUtils::toWindowsLocalPath(const QString &path)
|
||||||
|
{
|
||||||
|
QString p = CFileUtils::fixWindowsUncPath(path);
|
||||||
|
return p.replace('/', '\\');
|
||||||
|
}
|
||||||
|
|
||||||
QString CFileUtils::humanReadableFileSize(qint64 size)
|
QString CFileUtils::humanReadableFileSize(qint64 size)
|
||||||
{
|
{
|
||||||
// from https://stackoverflow.com/a/30958189/356726
|
// from https://stackoverflow.com/a/30958189/356726
|
||||||
|
|||||||
@@ -151,6 +151,9 @@ namespace BlackMisc
|
|||||||
//! Fix UNC file paths
|
//! Fix UNC file paths
|
||||||
static QStringList fixWindowsUncPaths(const QStringList &filePaths);
|
static QStringList fixWindowsUncPaths(const QStringList &filePaths);
|
||||||
|
|
||||||
|
//! To Windows path using "\" delimiter
|
||||||
|
static QString toWindowsLocalPath(const QString &path);
|
||||||
|
|
||||||
//! Human readable (GB, MB, ..) file size
|
//! Human readable (GB, MB, ..) file size
|
||||||
static QString humanReadableFileSize(qint64 size);
|
static QString humanReadableFileSize(qint64 size);
|
||||||
|
|
||||||
|
|||||||
@@ -331,6 +331,14 @@ namespace BlackMisc
|
|||||||
if (in.isEmpty()) { return ignoreEmpty ? e : ea; }
|
if (in.isEmpty()) { return ignoreEmpty ? e : ea; }
|
||||||
return QStringLiteral("'") % in % QStringLiteral("'");
|
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
|
//! \endcond
|
||||||
|
|||||||
@@ -123,6 +123,9 @@ namespace BlackMisc
|
|||||||
//! Return string in apostrophes
|
//! Return string in apostrophes
|
||||||
BLACKMISC_EXPORT const QString inApostrophes(const QString &in, bool ignoreEmpty = false);
|
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
|
//! Bool to on/off
|
||||||
BLACKMISC_EXPORT const QString &boolToOnOff(bool v);
|
BLACKMISC_EXPORT const QString &boolToOnOff(bool v);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user