代码拉取完成,页面将自动刷新
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
#include <QString>
#include <algorithm>
#define QTC_WIN_EXE_SUFFIX ".exe"
namespace Utils {
// Add more as needed.
enum OsType { OsTypeWindows, OsTypeLinux, OsTypeMac, OsTypeOtherUnix, OsTypeOther };
namespace OsSpecificAspects {
inline QString withExecutableSuffix(OsType osType, const QString &executable)
{
QString finalName = executable;
if (osType == OsTypeWindows && !finalName.endsWith(QTC_WIN_EXE_SUFFIX))
finalName += QLatin1String(QTC_WIN_EXE_SUFFIX);
return finalName;
}
constexpr Qt::CaseSensitivity fileNameCaseSensitivity(OsType osType)
{
return osType == OsTypeWindows || osType == OsTypeMac ? Qt::CaseInsensitive : Qt::CaseSensitive;
}
constexpr Qt::CaseSensitivity envVarCaseSensitivity(OsType osType)
{
return fileNameCaseSensitivity(osType);
}
constexpr QChar pathListSeparator(OsType osType)
{
return QLatin1Char(osType == OsTypeWindows ? ';' : ':');
}
constexpr Qt::KeyboardModifier controlModifier(OsType osType)
{
return osType == OsTypeMac ? Qt::MetaModifier : Qt::ControlModifier;
}
inline QString pathWithNativeSeparators(OsType osType, const QString &pathName)
{
if (osType == OsTypeWindows) {
const int pos = pathName.indexOf('/');
if (pos >= 0) {
QString n = pathName;
std::replace(std::begin(n) + pos, std::end(n), '/', '\\');
return n;
}
} else {
const int pos = pathName.indexOf('\\');
if (pos >= 0) {
QString n = pathName;
std::replace(std::begin(n) + pos, std::end(n), '\\', '/');
return n;
}
}
return pathName;
}
} // namespace OsSpecificAspects
} // namespace Utils
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。