logic: used wstring in FilePath constructor

* used wstring in FilePath constructor where easily possible
* added FilePath concatenate method that accepts string parameter
* implemented using only wstring in MessageStatus
* used wstring in config
This commit is contained in:
mlangkabel
2018-01-30 11:00:23 +01:00
parent 143cf6a02d
commit 0dda63f7ae
157 changed files with 1230 additions and 945 deletions
@@ -29,13 +29,9 @@ std::vector<FilePath> CxxVs10To14HeaderPathDetector::getPaths() const
std::vector<FilePath> headerSearchPaths;
if (vsInstallPath.exists())
{
std::vector<std::string> subdirectories;
subdirectories.push_back("vc/include");
subdirectories.push_back("vc/atlmfc/include");
for (size_t i = 0; i < subdirectories.size(); i++)
for (const std::wstring& subdirectory : { L"vc/include" , L"vc/atlmfc/include" })
{
FilePath headerSearchPath = vsInstallPath.getConcatenated(FilePath(subdirectories[i]));
FilePath headerSearchPath = vsInstallPath.getConcatenated(subdirectory);
if (headerSearchPath.exists())
{
headerSearchPaths.push_back(headerSearchPath.makeCanonical());
@@ -98,7 +94,7 @@ FilePath CxxVs10To14HeaderPathDetector::getVsInstallPathUsingRegistry() const
QSettings expressKey(key, QSettings::NativeFormat); // NativeFormat means from Registry on Windows.
QString value = expressKey.value("InstallDir").toString() + "../../";
FilePath path(value.toStdString());
FilePath path(value.toStdWString());
if (path.exists())
{
return path;
@@ -22,7 +22,7 @@ std::vector<FilePath> CxxVs15HeaderPathDetector::getPaths() const
std::vector<FilePath> headerSearchPaths;
{
const std::vector<FilePath> expandedPaths = FilePath("%ProgramFiles(x86)%/Microsoft Visual Studio/Installer/vswhere.exe").expandEnvironmentVariables();
const std::vector<FilePath> expandedPaths = FilePath(L"%ProgramFiles(x86)%/Microsoft Visual Studio/Installer/vswhere.exe").expandEnvironmentVariables();
if (!expandedPaths.empty())
{
const std::string command = "\"" + expandedPaths[0].str() + "\" -latest -property installationPath";
@@ -32,16 +32,16 @@ std::vector<FilePath> CxxVs15HeaderPathDetector::getPaths() const
const FilePath vsInstallPath(output);
if (vsInstallPath.exists())
{
for (const FilePath& versionPath : FileSystem::getDirectSubDirectories(vsInstallPath.getConcatenated(FilePath("VC/Tools/MSVC"))))
for (const FilePath& versionPath : FileSystem::getDirectSubDirectories(vsInstallPath.getConcatenated(L"VC/Tools/MSVC")))
{
if (versionPath.exists())
{
headerSearchPaths.push_back(versionPath.getConcatenated(FilePath("include")));
headerSearchPaths.push_back(versionPath.getConcatenated(FilePath("atlmfc/include")));
headerSearchPaths.push_back(versionPath.getConcatenated(L"include"));
headerSearchPaths.push_back(versionPath.getConcatenated(L"atlmfc/include"));
}
}
headerSearchPaths.push_back(vsInstallPath.getConcatenated(FilePath("VC/Auxiliary/VS/include")));
headerSearchPaths.push_back(vsInstallPath.getConcatenated(FilePath("VC/Auxiliary/VS/UnitTest/include")));
headerSearchPaths.push_back(vsInstallPath.getConcatenated(L"VC/Auxiliary/VS/include"));
headerSearchPaths.push_back(vsInstallPath.getConcatenated(L"VC/Auxiliary/VS/UnitTest/include"));
}
}
}
@@ -44,18 +44,13 @@ namespace utility
const FilePath sdkPath = getWindowsSdkRootPathUsingRegistry(architectureType, windowsSdkVersions[i]);
if (sdkPath.exists())
{
const FilePath sdkIncludePath = sdkPath.getConcatenated(FilePath("include/"));
const FilePath sdkIncludePath = sdkPath.getConcatenated(L"include/");
if (sdkIncludePath.exists())
{
std::vector<std::string> subdirectories;
subdirectories.push_back("shared");
subdirectories.push_back("um");
subdirectories.push_back("winrt");
bool usingSubdirectories = false;
for (size_t j = 0; j < subdirectories.size(); j++)
for (const std::wstring subDirectory : { L"shared", L"um", L"winrt" })
{
const FilePath sdkSubdirectory = sdkIncludePath.getConcatenated(FilePath(subdirectories[j]));
const FilePath sdkSubdirectory = sdkIncludePath.getConcatenated(subDirectory);
if (sdkSubdirectory.exists())
{
headerSearchPaths.push_back(sdkSubdirectory);
@@ -75,9 +70,9 @@ namespace utility
const FilePath sdkPath = getWindowsSdkRootPathUsingRegistry(architectureType, "v10.0");
if (sdkPath.exists())
{
for (const FilePath& versionPath : FileSystem::getDirectSubDirectories(sdkPath.getConcatenated(FilePath("include/"))))
for (const FilePath& versionPath : FileSystem::getDirectSubDirectories(sdkPath.getConcatenated(L"include/")))
{
const FilePath ucrtPath = versionPath.getConcatenated(FilePath("ucrt"));
const FilePath ucrtPath = versionPath.getConcatenated(L"ucrt");
if (ucrtPath.exists())
{
headerSearchPaths.push_back(ucrtPath);
@@ -102,7 +97,7 @@ namespace utility
QSettings expressKey(key, QSettings::NativeFormat); // NativeFormat means from Registry on Windows.
QString value = expressKey.value("InstallationFolder").toString();
FilePath path(value.toStdString());
FilePath path(value.toStdWString());
if (path.exists())
{
return path;
@@ -5,9 +5,9 @@
#include "utility/utilityString.h"
#ifdef __x86_64__
const char jvmLibPathRelativeToJavaExecutable[] = "/../lib/amd64/server/libjvm.so";
const wchar_t jvmLibPathRelativeToJavaExecutable[] = L"/../lib/amd64/server/libjvm.so";
#else
const char jvmLibPathRelativeToJavaExecutable[] = "/../lib/i386/server/libjvm.so";
const wchar_t jvmLibPathRelativeToJavaExecutable[] = L"/../lib/i386/server/libjvm.so";
#endif
@@ -25,7 +25,7 @@ FilePath JavaPathDetectorLinux::getJavaInPath() const
std::string command = "which java";
std::string output = utility::executeProcess(command.c_str());
if (output.size())
if (!output.empty())
{
output = utility::trim(output);
@@ -52,7 +52,7 @@ FilePath JavaPathDetectorLinux::readLink(const FilePath& path) const
FilePath JavaPathDetectorLinux::getFilePathRelativeToJavaExecutable(FilePath& javaExecutablePath) const
{
FilePath p(javaExecutablePath.getParentDirectory().str() + jvmLibPathRelativeToJavaExecutable);
FilePath p = javaExecutablePath.getParentDirectory().concatenate(jvmLibPathRelativeToJavaExecutable);
if (p.exists())
{
return p.makeCanonical();
@@ -90,20 +90,20 @@ std::vector<FilePath> JavaPathDetectorLinux::getPaths() const
{
std::vector<FilePath> paths;
FilePath p = getJavaInPath();
if( !p.empty() )
if(!p.empty())
{
paths.push_back(p);
}
p = getJavaInJavaHome();
if( !p.empty() )
if(!p.empty())
{
paths.push_back(p);
}
// some default paths for java
paths.push_back(FilePath("/etc/alternatives/java"));
paths.push_back(FilePath("/usr/lib/jvm/default/bin/java"));
paths.push_back(FilePath("/usr/lib/jvm/java-openjdk/bin/java"));
paths.push_back(FilePath(L"/etc/alternatives/java"));
paths.push_back(FilePath(L"/usr/lib/jvm/default/bin/java"));
paths.push_back(FilePath(L"/usr/lib/jvm/java-openjdk/bin/java"));
for (const FilePath& path : paths )
{
@@ -21,14 +21,14 @@ std::vector<FilePath> JavaPathDetectorMac::getPaths() const
std::string command = "/usr/libexec/java_home";
std::string output = utility::executeProcess(command.c_str());
if (output.size())
if (!output.empty())
{
javaPath = FilePath(utility::trim(output) + "/jre/lib/jli/libjli.dylib");
}
if (!javaPath.exists())
{
javaPath = FilePath("/usr/lib/libjli.dylib");
javaPath = FilePath(L"/usr/lib/libjli.dylib");
}
if (!javaPath.exists() && output.size())
@@ -38,7 +38,7 @@ std::vector<FilePath> JavaPathDetectorMac::getPaths() const
if (!javaPath.exists())
{
javaPath = FilePath("/usr/lib/libjvm.dylib");
javaPath = FilePath(L"/usr/lib/libjvm.dylib");
}
if (javaPath.exists())
@@ -29,7 +29,7 @@ std::vector<FilePath> JavaPathDetectorWindows::getPaths() const
QSettings expressKey(key, QSettings::NativeFormat); // NativeFormat means from Registry on Windows.
QString value = expressKey.value("RuntimeLib").toString();
FilePath path(value.toStdString());
FilePath path(value.toStdWString());
std::vector<FilePath> paths;
if (path.exists())
@@ -22,7 +22,7 @@ std::vector<FilePath> JreSystemLibraryPathDetector::getPaths() const
for (const FilePath& jrePath: m_javaPathDetector->getPaths())
{
const FilePath javaRoot = jrePath.getParentDirectory().getParentDirectory().getParentDirectory();
for (const FilePath& jarPath : FileSystem::getFilePathsFromDirectory(javaRoot.getConcatenated(FilePath("lib")), {".jar"}))
for (const FilePath& jarPath : FileSystem::getFilePathsFromDirectory(javaRoot.getConcatenated(L"lib"), {".jar"}))
{
paths.push_back(jarPath);
}
+3 -3
View File
@@ -165,9 +165,9 @@ bool utility::saveLicense(const License* license)
return false;
}
std::string appLocation = AppPath::getAppPath();
appSettings->setLicenseString(license->getLicenseEncodedString(appLocation));
appSettings->setLicenseCheck(license->hashLocation(FilePath(appLocation).makeAbsolute().str()));
const FilePath appLocation = AppPath::getAppPath();
appSettings->setLicenseString(license->getLicenseEncodedString(appLocation.str()));
appSettings->setLicenseCheck(license->hashLocation(appLocation.getAbsolute().str()));
appSettings->save();
return true;
}
+15
View File
@@ -0,0 +1,15 @@
#include "utility/utilityQString.h"
#include <QString>
std::wstring utility::decodeFromUtf8(std::string s)
{
QString qs = QString::fromUtf8(s.c_str());
return qs.toStdWString();
}
std::string utility::encodeToUtf8(std::wstring s)
{
QString qs = QString::fromStdWString(s);
return qs.toUtf8().toStdString();
}
+13
View File
@@ -0,0 +1,13 @@
#ifndef UTILITY_Q_STRING_H
#define UTILITY_Q_STRING_H
#include <string>
namespace utility
{
std::wstring decodeFromUtf8(std::string s);
std::string encodeToUtf8(std::wstring s);
}
#endif // UTILITY_Q_STRING_H