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 outputPath = minecraftInstance->getNativePath();
FS::ensureFolderPathExists(outputPath);
auto javaVersion = minecraftInstance->getJavaVersion();
bool jniHackEnabled = javaVersion.major() >= 8;
for (const auto& source : toExtract) {

View File

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

View File

@ -88,20 +88,15 @@ QString shortPathName(const QString& file)
return ret;
}
QString getShortPathName(const QString& file)
QString getPathNameInLocal8bit(const QString& file)
{
if (!fitsInLocal8bit(file)) {
auto path = shortPathName(file);
if (!path.isEmpty())
if (!path.isEmpty()) {
return path;
// the path can not be getted due to the file/folder not existing
// so create the parrent folder
// 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());
}
// in case shortPathName fails just return the path as is
}
return file;
}
#endif
@ -156,24 +151,15 @@ void LauncherPartLaunch::executeTask()
auto natPath = minecraftInstance->getNativePath();
#ifdef Q_OS_WIN
if (!fitsInLocal8bit(natPath)) {
args << "-Djava.library.path=" + getShortPathName(natPath);
} else {
args << "-Djava.library.path=" + natPath;
}
#else
args << "-Djava.library.path=" + natPath;
natPath = getPathNameInLocal8bit(natPath);
#endif
args << "-Djava.library.path=" + natPath;
args << "-cp";
#ifdef Q_OS_WIN
QStringList processed;
for (auto& item : classPath) {
if (!fitsInLocal8bit(item)) {
processed << getShortPathName(item);
} else {
processed << item;
}
processed << getPathNameInLocal8bit(item);
}
args << processed.join(';');
#else