MCPcopy Create free account
hub / github.com/PrismLauncher/PrismLauncher / getMinecraftJavaBundle

Function getMinecraftJavaBundle

launcher/java/JavaUtils.cpp:516–558  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

514}
515
516QStringList getMinecraftJavaBundle()
517{
518 QStringList processpaths;
519#if defined(Q_OS_MACOS)
520 processpaths << FS::PathCombine(QDir::homePath(), FS::PathCombine("Library", "Application Support", "minecraft", "runtime"));
521#elif defined(Q_OS_WIN32)
522
523 auto appDataPath = QProcessEnvironment::systemEnvironment().value("APPDATA", "");
524 processpaths << FS::PathCombine(QFileInfo(appDataPath).absoluteFilePath(), ".minecraft", "runtime");
525
526 // add the microsoft store version of the launcher to the search. the current path is:
527 // C:\Users\USERNAME\AppData\Local\Packages\Microsoft.4297127D64EC6_8wekyb3d8bbwe\LocalCache\Local\runtime
528 auto localAppDataPath = QProcessEnvironment::systemEnvironment().value("LOCALAPPDATA", "");
529 auto minecraftMSStorePath =
530 FS::PathCombine(QFileInfo(localAppDataPath).absoluteFilePath(), "Packages", "Microsoft.4297127D64EC6_8wekyb3d8bbwe");
531 processpaths << FS::PathCombine(minecraftMSStorePath, "LocalCache", "Local", "runtime");
532#else
533 processpaths << FS::PathCombine(QDir::homePath(), ".minecraft", "runtime");
534#endif
535
536 QStringList javas;
537 while (!processpaths.isEmpty()) {
538 auto dirPath = processpaths.takeFirst();
539 QDir dir(dirPath);
540 if (!dir.exists())
541 continue;
542 auto entries = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
543 auto binFound = false;
544 for (auto& entry : entries) {
545 if (entry.baseName() == "bin") {
546 javas.append(FS::PathCombine(entry.canonicalFilePath(), JavaUtils::javaExecutable));
547 binFound = true;
548 break;
549 }
550 }
551 if (!binFound) {
552 for (auto& entry : entries) {
553 processpaths << entry.canonicalFilePath();
554 }
555 }
556 }
557 return javas;
558}
559
560#if defined(Q_OS_WIN32)
561const QString JavaUtils::javaExecutable = "javaw.exe";

Callers 1

FindJavaPathsMethod · 0.85

Calls 7

PathCombineFunction · 0.85
QFileInfoClass · 0.85
valueMethod · 0.80
appendMethod · 0.80
canonicalFilePathMethod · 0.80
isEmptyMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected