Moved the creation of natives folder in ExtractNatives task

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
(cherry picked from commit 8ecab305ac)
This commit is contained in:
Trial97 2024-04-04 13:49:27 +03:00 committed by github-actions[bot]
parent 1e5a29c423
commit 3e5e131a94
3 changed files with 12 additions and 27 deletions

View File

@ -79,6 +79,7 @@ void ExtractNatives::executeTask()
auto settings = minecraftInstance->settings(); auto settings = minecraftInstance->settings();
auto outputPath = minecraftInstance->getNativePath(); auto outputPath = minecraftInstance->getNativePath();
FS::ensureFolderPathExists(outputPath);
auto javaVersion = minecraftInstance->getJavaVersion(); auto javaVersion = minecraftInstance->getJavaVersion();
bool jniHackEnabled = javaVersion.major() >= 8; bool jniHackEnabled = javaVersion.major() >= 8;
for (const auto& source : toExtract) { for (const auto& source : toExtract) {

View File

@ -16,8 +16,6 @@
#pragma once #pragma once
#include <launch/LaunchStep.h> #include <launch/LaunchStep.h>
#include <memory>
#include "minecraft/auth/AuthSession.h"
// FIXME: temporary wrapper for existing task. // FIXME: temporary wrapper for existing task.
class ExtractNatives : public LaunchStep { class ExtractNatives : public LaunchStep {

View File

@ -88,20 +88,15 @@ QString shortPathName(const QString& file)
return ret; return ret;
} }
QString getShortPathName(const QString& file) QString getPathNameInLocal8bit(const QString& file)
{ {
auto path = shortPathName(file); if (!fitsInLocal8bit(file)) {
if (!path.isEmpty()) auto path = shortPathName(file);
return path; if (!path.isEmpty()) {
// the path can not be getted due to the file/folder not existing return path;
// so create the parrent folder }
// and assume that we can concatenate the short path of the parent folder with the file name // in case shortPathName fails just return the path as is
// usually the 8 bit characters are in the instance name not in the name of the end files/folders we need }
FS::ensureFilePathExists(file);
QFileInfo a(file);
auto partialShortPath = shortPathName(a.path());
if (!partialShortPath.isEmpty())
return FS::PathCombine(partialShortPath, a.fileName());
return file; return file;
} }
#endif #endif
@ -156,24 +151,15 @@ void LauncherPartLaunch::executeTask()
auto natPath = minecraftInstance->getNativePath(); auto natPath = minecraftInstance->getNativePath();
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
if (!fitsInLocal8bit(natPath)) { natPath = getPathNameInLocal8bit(natPath);
args << "-Djava.library.path=" + getShortPathName(natPath);
} else {
args << "-Djava.library.path=" + natPath;
}
#else
args << "-Djava.library.path=" + natPath;
#endif #endif
args << "-Djava.library.path=" + natPath;
args << "-cp"; args << "-cp";
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
QStringList processed; QStringList processed;
for (auto& item : classPath) { for (auto& item : classPath) {
if (!fitsInLocal8bit(item)) { processed << getPathNameInLocal8bit(item);
processed << getShortPathName(item);
} else {
processed << item;
}
} }
args << processed.join(';'); args << processed.join(';');
#else #else