Apply suggestion from code review

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2024-06-25 16:10:05 +03:00
parent 555c4a7c59
commit 7c38edc93d
8 changed files with 75 additions and 67 deletions

View File

@ -463,12 +463,10 @@ QString JavaUtils::getJavaCheckPath()
QStringList getMinecraftJavaBundle()
{
QString executable = "java";
QStringList processpaths;
#if defined(Q_OS_OSX)
processpaths << FS::PathCombine(QDir::homePath(), FS::PathCombine("Library", "Application Support", "minecraft", "runtime"));
#elif defined(Q_OS_WIN32)
executable += "w.exe";
auto appDataPath = QProcessEnvironment::systemEnvironment().value("APPDATA", "");
processpaths << FS::PathCombine(QFileInfo(appDataPath).absoluteFilePath(), ".minecraft", "runtime");
@ -493,7 +491,7 @@ QStringList getMinecraftJavaBundle()
auto binFound = false;
for (auto& entry : entries) {
if (entry.baseName() == "bin") {
javas.append(FS::PathCombine(entry.canonicalFilePath(), executable));
javas.append(FS::PathCombine(entry.canonicalFilePath(), JavaUtils::javaExecutable));
binFound = true;
break;
}
@ -507,19 +505,20 @@ QStringList getMinecraftJavaBundle()
return javas;
}
#if defined(Q_OS_WIN32)
const QString JavaUtils::javaExecutable = "javaw.exe";
#else
const QString JavaUtils::javaExecutable = "java";
#endif
QStringList getPrismJavaBundle()
{
QList<QString> javas;
QString executable = "java";
#if defined(Q_OS_WIN32)
executable += "w.exe";
#endif
auto scanDir = [&](QString prefix) {
javas.append(FS::PathCombine(prefix, "jre", "bin", executable));
javas.append(FS::PathCombine(prefix, "bin", executable));
javas.append(FS::PathCombine(prefix, executable));
javas.append(FS::PathCombine(prefix, "jre", "bin", JavaUtils::javaExecutable));
javas.append(FS::PathCombine(prefix, "bin", JavaUtils::javaExecutable));
javas.append(FS::PathCombine(prefix, JavaUtils::javaExecutable));
};
auto scanJavaDir = [&](const QString& dirPath) {
QDir dir(dirPath);