Moved the creation of natives folder in ExtractNatives task

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2024-04-04 13:49:27 +03:00
parent 450b73328e
commit 8ecab305ac
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
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)
{ {
if (!fitsInLocal8bit(file)) {
auto path = shortPathName(file); auto path = shortPathName(file);
if (!path.isEmpty()) if (!path.isEmpty()) {
return path; return path;
// the path can not be getted due to the file/folder not existing }
// so create the parrent folder // in case shortPathName fails just return the path as is
// and assume that we can concatenate the short path of the parent folder with the file name }
// 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