Added JavaPath function
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
82b15268bc
commit
ba990e075b
@ -48,7 +48,6 @@
|
||||
#include "net/PasteUpload.h"
|
||||
#include "pathmatcher/MultiMatcher.h"
|
||||
#include "pathmatcher/SimplePrefixMatcher.h"
|
||||
#include "settings/INIFile.h"
|
||||
#include "ui/InstanceWindow.h"
|
||||
#include "ui/MainWindow.h"
|
||||
|
||||
@ -106,8 +105,6 @@
|
||||
#include "icons/IconList.h"
|
||||
#include "net/HttpMetaCache.h"
|
||||
|
||||
#include "java/JavaUtils.h"
|
||||
|
||||
#include "updater/ExternalUpdater.h"
|
||||
|
||||
#include "tools/JProfiler.h"
|
||||
@ -1833,3 +1830,7 @@ QUrl Application::normalizeImportUrl(QString const& url)
|
||||
return QUrl::fromUserInput(url);
|
||||
}
|
||||
}
|
||||
const QString Application::javaPath()
|
||||
{
|
||||
return FS::PathCombine(m_dataPath, "java");
|
||||
}
|
||||
|
@ -162,6 +162,9 @@ class Application : public QApplication {
|
||||
/// the data path the application is using
|
||||
const QString& dataRoot() { return m_dataPath; }
|
||||
|
||||
/// the java installed path the application is using
|
||||
const QString javaPath();
|
||||
|
||||
bool isPortable() { return m_portable; }
|
||||
|
||||
const Capabilities capabilities() { return m_capabilities; }
|
||||
|
@ -337,6 +337,7 @@ QList<QString> JavaUtils::FindJavaPaths()
|
||||
}
|
||||
|
||||
candidates.append(getMinecraftJavaBundle());
|
||||
candidates.append(getPrismJavaBundle());
|
||||
candidates = addJavasFromEnv(candidates);
|
||||
candidates.removeDuplicates();
|
||||
return candidates;
|
||||
@ -363,6 +364,7 @@ QList<QString> JavaUtils::FindJavaPaths()
|
||||
javas.append(systemLibraryJVMDir.absolutePath() + "/" + java + "/Contents/Commands/java");
|
||||
}
|
||||
javas.append(getMinecraftJavaBundle());
|
||||
javas.append(getPrismJavaBundle());
|
||||
javas = addJavasFromEnv(javas);
|
||||
javas.removeDuplicates();
|
||||
return javas;
|
||||
@ -393,7 +395,6 @@ QList<QString> JavaUtils::FindJavaPaths()
|
||||
scanJavaDir(snap + dirPath);
|
||||
}
|
||||
};
|
||||
scanJavaDir(FS::PathCombine(APPLICATION->dataRoot(), "java"));
|
||||
// oracle RPMs
|
||||
scanJavaDirs("/usr/java");
|
||||
// general locations used by distro packaging
|
||||
@ -416,6 +417,7 @@ QList<QString> JavaUtils::FindJavaPaths()
|
||||
scanJavaDirs(FS::PathCombine(home, ".sdkman/candidates/java"));
|
||||
|
||||
javas.append(getMinecraftJavaBundle());
|
||||
javas.append(getPrismJavaBundle());
|
||||
javas = addJavasFromEnv(javas);
|
||||
javas.removeDuplicates();
|
||||
return javas;
|
||||
@ -429,6 +431,8 @@ QList<QString> JavaUtils::FindJavaPaths()
|
||||
javas.append(this->GetDefaultJava()->path);
|
||||
|
||||
javas.append(getMinecraftJavaBundle());
|
||||
javas.append(getPrismJavaBundle());
|
||||
javas.removeDuplicates();
|
||||
return addJavasFromEnv(javas);
|
||||
}
|
||||
#endif
|
||||
@ -484,3 +488,25 @@ QStringList getMinecraftJavaBundle()
|
||||
}
|
||||
return javas;
|
||||
}
|
||||
|
||||
QStringList getPrismJavaBundle()
|
||||
{
|
||||
QList<QString> javas;
|
||||
QDir dir(APPLICATION->javaPath());
|
||||
if (!dir.exists())
|
||||
return javas;
|
||||
|
||||
QString executable = "java";
|
||||
#if defined(Q_OS_WIN32)
|
||||
executable += "w.exe";
|
||||
#endif
|
||||
|
||||
auto entries = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (auto& entry : entries) {
|
||||
QString prefix;
|
||||
prefix = entry.canonicalFilePath();
|
||||
javas.append(FS::PathCombine(prefix, "jre", "bin", executable));
|
||||
javas.append(FS::PathCombine(prefix, "bin", executable));
|
||||
}
|
||||
return javas;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
QString stripVariableEntries(QString name, QString target, QString remove);
|
||||
QProcessEnvironment CleanEnviroment();
|
||||
QStringList getMinecraftJavaBundle();
|
||||
QStringList getPrismJavaBundle();
|
||||
|
||||
class JavaUtils : public QObject {
|
||||
Q_OBJECT
|
||||
|
@ -85,7 +85,7 @@ void Downloader::accept()
|
||||
return;
|
||||
}
|
||||
Task::Ptr task;
|
||||
auto final_path = FS::PathCombine(APPLICATION->dataRoot(), "java", meta->vendor, meta->m_name);
|
||||
auto final_path = FS::PathCombine(APPLICATION->javaPath(), meta->m_name);
|
||||
switch (meta->downloadType) {
|
||||
case Java::DownloadType::Manifest:
|
||||
task = makeShared<ManifestDownloadTask>(meta->url, final_path, meta->checksumType, meta->checksumHash);
|
||||
|
Loading…
Reference in New Issue
Block a user