mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 12:48:04 -06:00
@@ -80,12 +80,12 @@ bool Utils::Fs::smartRemoveEmptyFolderTree(const Path &path)
|
||||
const QStringList deleteFilesList =
|
||||
{
|
||||
// Windows
|
||||
QLatin1String("Thumbs.db"),
|
||||
QLatin1String("desktop.ini"),
|
||||
u"Thumbs.db"_qs,
|
||||
u"desktop.ini"_qs,
|
||||
// Linux
|
||||
QLatin1String(".directory"),
|
||||
u".directory"_qs,
|
||||
// Mac OS
|
||||
QLatin1String(".DS_Store")
|
||||
u".DS_Store"_qs
|
||||
};
|
||||
|
||||
// travel from the deepest folder and remove anything unwanted on the way out.
|
||||
@@ -182,7 +182,7 @@ bool Utils::Fs::sameFiles(const Path &path1, const Path &path2)
|
||||
|
||||
QString Utils::Fs::toValidFileName(const QString &name, const QString &pad)
|
||||
{
|
||||
const QRegularExpression regex {QLatin1String("[\\\\/:?\"*<>|]+")};
|
||||
const QRegularExpression regex {u"[\\\\/:?\"*<>|]+"_qs};
|
||||
|
||||
QString validName = name.trimmed();
|
||||
validName.replace(regex, pad);
|
||||
@@ -192,7 +192,7 @@ QString Utils::Fs::toValidFileName(const QString &name, const QString &pad)
|
||||
|
||||
Path Utils::Fs::toValidPath(const QString &name, const QString &pad)
|
||||
{
|
||||
const QRegularExpression regex {QLatin1String("[:?\"*<>|]+")};
|
||||
const QRegularExpression regex {u"[:?\"*<>|]+"_qs};
|
||||
|
||||
QString validPathStr = name;
|
||||
validPathStr.replace(regex, pad);
|
||||
@@ -238,7 +238,7 @@ bool Utils::Fs::isNetworkFileSystem(const Path &path)
|
||||
return false;
|
||||
return (::GetDriveTypeW(volumePath.get()) == DRIVE_REMOTE);
|
||||
#else
|
||||
const QString file = path.toString() + QLatin1String("/.");
|
||||
const QString file = (path.toString() + u"/.");
|
||||
struct statfs buf {};
|
||||
if (statfs(file.toLocal8Bit().constData(), &buf) != 0)
|
||||
return false;
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "base/global.h"
|
||||
#include "base/pathfwd.h"
|
||||
|
||||
class QDateTime;
|
||||
@@ -52,8 +53,8 @@ namespace Utils::Fs
|
||||
QDateTime lastModified(const Path &path);
|
||||
bool sameFiles(const Path &path1, const Path &path2);
|
||||
|
||||
QString toValidFileName(const QString &name, const QString &pad = QLatin1String(" "));
|
||||
Path toValidPath(const QString &name, const QString &pad = QLatin1String(" "));
|
||||
QString toValidFileName(const QString &name, const QString &pad = u" "_qs);
|
||||
Path toValidPath(const QString &name, const QString &pad = u" "_qs);
|
||||
Path toCanonicalPath(const Path &path);
|
||||
|
||||
bool copyFile(const Path &from, const Path &to);
|
||||
|
||||
@@ -298,8 +298,8 @@ bool Utils::Misc::isPreviewable(const Path &filePath)
|
||||
{
|
||||
const QString mime = QMimeDatabase().mimeTypeForFile(filePath.data(), QMimeDatabase::MatchExtension).name();
|
||||
|
||||
if (mime.startsWith(QLatin1String("audio"), Qt::CaseInsensitive)
|
||||
|| mime.startsWith(QLatin1String("video"), Qt::CaseInsensitive))
|
||||
if (mime.startsWith(u"audio", Qt::CaseInsensitive)
|
||||
|| mime.startsWith(u"video", Qt::CaseInsensitive))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
#include "base/global.h"
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
namespace Net
|
||||
@@ -65,7 +67,7 @@ namespace Utils
|
||||
{
|
||||
return (addr == QHostAddress::LocalHost)
|
||||
|| (addr == QHostAddress::LocalHostIPv6)
|
||||
|| (addr == QHostAddress(QLatin1String("::ffff:127.0.0.1")));
|
||||
|| (addr == QHostAddress(u"::ffff:127.0.0.1"_qs));
|
||||
}
|
||||
|
||||
bool isIPInRange(const QHostAddress &addr, const QVector<Subnet> &subnets)
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <QString>
|
||||
|
||||
#include "base/exceptions.h"
|
||||
#include "base/global.h"
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
@@ -63,7 +64,7 @@ namespace Utils
|
||||
* @throws RuntimeError if parsing fails
|
||||
*/
|
||||
Version(const QString &version)
|
||||
: Version {version.split(QLatin1Char('.'))}
|
||||
: Version {version.split(u'.')}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -119,7 +120,7 @@ namespace Utils
|
||||
|
||||
QString res = QString::number((*this)[0]);
|
||||
for (std::size_t i = 1; i <= lastSignificantIndex; ++i)
|
||||
res += QLatin1Char('.') + QString::number((*this)[i]);
|
||||
res += (u'.' + QString::number((*this)[i]));
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -162,7 +163,7 @@ namespace Utils
|
||||
if ((static_cast<std::size_t>(versionParts.size()) > N)
|
||||
|| (static_cast<std::size_t>(versionParts.size()) < Mandatory))
|
||||
{
|
||||
throw RuntimeError(QLatin1String("Incorrect number of version components"));
|
||||
throw RuntimeError(u"Incorrect number of version components"_qs);
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
@@ -171,7 +172,7 @@ namespace Utils
|
||||
{
|
||||
res[i] = static_cast<T>(versionParts[static_cast<typename StringsList::size_type>(i)].toInt(&ok));
|
||||
if (!ok)
|
||||
throw RuntimeError(QLatin1String("Can not parse version component"));
|
||||
throw RuntimeError(u"Can not parse version component"_qs);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user