Checks: '-*,
cppcoreguidelines-init-variables,
modernize-make-*,
+ modernize-raw-string-literal,
modernize-redundant-void-arg,
modernize-replace-*,
modernize-return-braced-init-list,
wchar_t szSubkey[MAX_PATH];
// Create the HKCR\CLSID\{<CLSID>} key.
- hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey), L"CLSID\\%s", szCLSID);
+ hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey), LR"(CLSID\%s)", szCLSID);
if (SUCCEEDED(hr))
{
hr = SetHKCRRegistryKeyAndValue(szSubkey, nullptr, pszFriendlyName);
if (SUCCEEDED(hr))
{
hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey),
- L"CLSID\\%s\\InprocServer32", szCLSID);
+ LR"(CLSID\%s\InprocServer32)", szCLSID);
if (SUCCEEDED(hr))
{
// Set the default value of the InprocServer32 key to the
wchar_t szSubkey[MAX_PATH];
// Delete the HKCR\CLSID\{<CLSID>} key.
- hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey), L"CLSID\\%s", szCLSID);
+ hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey), LR"(CLSID\%s)", szCLSID);
if (SUCCEEDED(hr))
{
hr = HRESULT_FROM_WIN32(RegDelnode(HKEY_CLASSES_ROOT, szSubkey));
// Create the key HKCR\<File Type>\shellex\ContextMenuHandlers\{friendlyName>}
hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey),
- L"%s\\shellex\\ContextMenuHandlers\\%s", pszFileType, pszFriendlyName);
+ LR"(%s\shellex\ContextMenuHandlers\%s)", pszFileType, pszFriendlyName);
if (SUCCEEDED(hr))
{
// Set the default value of the key.
// Remove the HKCR\<File Type>\shellex\ContextMenuHandlers\{friendlyName} key.
hr = StringCchPrintf(szSubkey, ARRAYSIZE(szSubkey),
- L"%s\\shellex\\ContextMenuHandlers\\%s", pszFileType, pszFriendlyName);
+ LR"(%s\shellex\ContextMenuHandlers\%s)", pszFileType, pszFriendlyName);
if (SUCCEEDED(hr))
{
hr = HRESULT_FROM_WIN32(RegDelnode(HKEY_CLASSES_ROOT, szSubkey));
std::wstring CommunicationSocket::DefaultPipePath()
{
- auto pipename = std::wstring(L"\\\\.\\pipe\\");
+ auto pipename = std::wstring(LR"(\\.\pipe\)");
pipename += L"ownCloud-";
pipename += getUserName();
return pipename;
if( str[0] == '/' || str[0] == '\\' ) {
// Don't prepend if already UNC
if( !(len > 1 && (str[1] == '/' || str[1] == '\\')) ) {
- longStr.append("\\\\?");
+ longStr.append(R"(\\?)");
}
} else {
- longStr.append("\\\\?\\"); // prepend string by this four magic chars.
+ longStr.append(R"(\\?\)"); // prepend string by this four magic chars.
}
longStr += str;
QString Utility::sanitizeForFileName(const QString &name)
{
- const auto invalid = QStringLiteral("/?<>\\:*|\"");
+ const auto invalid = QStringLiteral(R"(/?<>\:*|")");
QString result;
result.reserve(name.size());
for (const auto c : name) {
#include <string>
#include <QLibrary>
-static const char runPathC[] = "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run";
+static const char runPathC[] = R"(HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run)";
namespace OCC {
static inline bool hasDarkSystray_private()
{
if(Utility::registryGetKeyValue( HKEY_CURRENT_USER,
- "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
+ R"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)",
"SystemUsesLightTheme" ) == 1) {
return false;
}
#ifdef Q_OS_WIN
Utility::registryWalkSubKeys(
HKEY_CURRENT_USER,
- QStringLiteral("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace"),
+ QStringLiteral(R"(Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace)"),
[&entriesToRemove](HKEY key, const QString &subKey) {
QVariant appName = Utility::registryGetKeyValue(key, subKey, QStringLiteral("ApplicationName"));
if (appName.toString() == QLatin1String(APPLICATION_NAME)) {
// Step 11: Register your extension in the namespace root
Utility::registrySetKeyValue(HKEY_CURRENT_USER, namespacePath, QString(), REG_SZ, title);
// Step 12: Hide your extension from the Desktop
- Utility::registrySetKeyValue(HKEY_CURRENT_USER, QStringLiteral("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\HideDesktopIcons\\NewStartPanel"), clsidStr, REG_DWORD, 0x1);
+ Utility::registrySetKeyValue(HKEY_CURRENT_USER, QStringLiteral(R"(Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel)"), clsidStr, REG_DWORD, 0x1);
// For us, to later be able to iterate and find our own namespace entries and associated CLSID.
// Use the macro instead of the theme to make sure it matches with the uninstaller.
{
(void)state;
- QByteArray line = "keep \\' \\\" \\? \\\\ \\a \\b \\f \\n \\r \\t \\v \\z \\#";
+ QByteArray line = R"(keep \' \" \? \\ \a \b \f \n \r \t \v \z \#)";
csync_exclude_expand_escapes(line);
assert_true(0 == strcmp(line.constData(), "keep ' \" ? \\\\ \a \b \f \n \r \t \v \\z #"));
{
const char *path = "C://DATA/FILES/MUSIC/MY_MUSIC.mp3"; // check a short path
- const char *exp_path = "\\\\?\\C:\\\\DATA\\FILES\\MUSIC\\MY_MUSIC.mp3";
+ const char *exp_path = R"(\\?\C:\\DATA\FILES\MUSIC\MY_MUSIC.mp3)";
QByteArray new_short = OCC::FileSystem::pathtoUNC(QByteArray::fromRawData(path, strlen(path)));
assert_string_equal(new_short, exp_path);
}
{
- const char *path = "\\\\foo\\bar/MY_MUSIC.mp3";
- const char *exp_path = "\\\\foo\\bar\\MY_MUSIC.mp3";
+ const char *path = R"(\\foo\bar/MY_MUSIC.mp3)";
+ const char *exp_path = R"(\\foo\bar\MY_MUSIC.mp3)";
QByteArray new_short = OCC::FileSystem::pathtoUNC(QByteArray::fromRawData(path, strlen(path)));
assert_string_equal(new_short, exp_path);
}
{
- const char *path = "//foo\\bar/MY_MUSIC.mp3";
- const char *exp_path = "\\\\foo\\bar\\MY_MUSIC.mp3";
+ const char *path = R"(//foo\bar/MY_MUSIC.mp3)";
+ const char *exp_path = R"(\\foo\bar\MY_MUSIC.mp3)";
QByteArray new_short = OCC::FileSystem::pathtoUNC(QByteArray::fromRawData(path, strlen(path)));
assert_string_equal(new_short, exp_path);
}
{
const char *path = "\\foo\\bar";
- const char *exp_path = "\\\\?\\foo\\bar";
+ const char *exp_path = R"(\\?\foo\bar)";
QByteArray new_short = OCC::FileSystem::pathtoUNC(QByteArray::fromRawData(path, strlen(path)));
assert_string_equal(new_short, exp_path);
}
{
const char *path = "/foo/bar";
- const char *exp_path = "\\\\?\\foo\\bar";
+ const char *exp_path = R"(\\?\foo\bar)";
QByteArray new_short = OCC::FileSystem::pathtoUNC(QByteArray::fromRawData(path, strlen(path)));
assert_string_equal(new_short, exp_path);
}
"elonglonglonglong/flonglonglonglong/glonglonglonglong/hlonglonglonglong/ilonglonglonglong/"
"jlonglonglonglong/klonglonglonglong/llonglonglonglong/mlonglonglonglong/nlonglonglonglong/"
"olonglonglonglong/file.txt";
- const char *longPathConv = "\\\\?\\D:\\\\alonglonglonglong\\blonglonglonglong\\clonglonglonglong\\dlonglonglonglong\\"
- "elonglonglonglong\\flonglonglonglong\\glonglonglonglong\\hlonglonglonglong\\ilonglonglonglong\\"
- "jlonglonglonglong\\klonglonglonglong\\llonglonglonglong\\mlonglonglonglong\\nlonglonglonglong\\"
- "olonglonglonglong\\file.txt";
+ const char *longPathConv = R"(\\?\D:\\alonglonglonglong\blonglonglonglong\clonglonglonglong\dlonglonglonglong\)"
+ R"(elonglonglonglong\flonglonglonglong\glonglonglonglong\hlonglonglonglong\ilonglonglonglong\)"
+ R"(jlonglonglonglong\klonglonglonglong\llonglonglonglong\mlonglonglonglong\nlonglonglonglong\)"
+ R"(olonglonglonglong\file.txt)";
QByteArray new_long = OCC::FileSystem::pathtoUNC(QByteArray::fromRawData(longPath, strlen(longPath)));
// printf("XXXXXXXXXXXX %s %d\n", new_long, mem_reserved);