Cleanup: remove legacy code and data migration
This commit is contained in:
1 parent
4cf5906be0
commit
958a668f7f
5 files changed
+15
-76
No files matched your search
@@ -37,9 +37,8 @@ public class PojavLauncher {
|
||||
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
|
||||
public void uncaughtException(Thread t, Throwable th) {
|
||||
Tools.showError(th);
|
||||
// Block this thread from exiting
|
||||
while (true) {}
|
||||
th.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -225,24 +225,7 @@ public final class Tools {
|
||||
|
||||
return libStr.toString();
|
||||
}
|
||||
|
||||
public static void showError(Throwable e) {
|
||||
showError(e, false);
|
||||
}
|
||||
|
||||
public static void showError(final Throwable e, final boolean exitIfOk) {
|
||||
showError("Error", e, exitIfOk, false);
|
||||
}
|
||||
|
||||
public static void showError(final String title, final Throwable e, final boolean exitIfOk) {
|
||||
showError(title, e, exitIfOk, false);
|
||||
}
|
||||
|
||||
private static void showError(final String title, final Throwable e, final boolean exitIfOk, final boolean showMore) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
|
||||
public static void moveInside(String from, String to) {
|
||||
File fromFile = new File(from);
|
||||
for (File fromInside : fromFile.listFiles()) {
|
||||
|
||||
@@ -372,10 +372,8 @@ static void *ProgressObserverContext = &ProgressObserverContext;
|
||||
BOOL hasTrollStoreJIT = getEntitlementValue(@"com.apple.private.local.sandboxed-jit");
|
||||
|
||||
if (isJITEnabled(false)) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[ALTServerManager.sharedManager stopDiscovering];
|
||||
handler();
|
||||
});
|
||||
[ALTServerManager.sharedManager stopDiscovering];
|
||||
handler();
|
||||
return;
|
||||
} else if (hasTrollStoreJIT) {
|
||||
NSURL *jitURL = [NSURL URLWithString:[NSString stringWithFormat:@"apple-magnifier://enable-jit?bundle-id=%@", NSBundle.mainBundle.bundleIdentifier]];
|
||||
|
||||
+10
-45
@@ -127,41 +127,6 @@ void init_logDeviceAndVer(char *argument) {
|
||||
//printEntitlementAvailability(@"dynamic-codesigning");
|
||||
}
|
||||
|
||||
void init_migrateDirIfNecessary() {
|
||||
NSString *oldDir = @"/usr/share/pojavlauncher";
|
||||
if ([fm fileExistsAtPath:oldDir]) {
|
||||
NSString *newDir = @"";
|
||||
if ([@(getenv("HOME")) isEqualToString:@"/var/mobile"]) {
|
||||
newDir = [NSString stringWithFormat:@"%s/Documents/PojavLauncher", getenv("HOME")];
|
||||
} else {
|
||||
newDir = [NSString stringWithFormat:@"%s/Documents", getenv("HOME")];
|
||||
}
|
||||
[fm moveItemAtPath:oldDir toPath:newDir error:nil];
|
||||
[fm removeItemAtPath:oldDir error:nil];
|
||||
}
|
||||
}
|
||||
|
||||
void init_migrateToPlist(char* prefKey, char* filename) {
|
||||
NSError *error;
|
||||
NSString *path_str = [NSString stringWithFormat:@"%s/%s", getenv("POJAV_HOME"), filename];
|
||||
NSDebugLog(@"[Pre-Init] Beginning migration for file \"%s\"", filename);
|
||||
NSString *str = [NSString stringWithContentsOfFile:path_str encoding:NSUTF8StringEncoding error:&error];
|
||||
if (error == nil && ![str hasPrefix:@"#README"]) {
|
||||
NSString *finalized = @"";
|
||||
for (NSString *line in [str componentsSeparatedByCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet]) {
|
||||
if (![line hasPrefix:@"#"]) {
|
||||
finalized = [finalized stringByAppendingString:[NSString stringWithFormat:@"%@ ", line]];
|
||||
}
|
||||
}
|
||||
|
||||
setPrefObject(@(prefKey), finalized);
|
||||
[@"#README - this file has been merged into launcher_preferences.plist" writeToFile:path_str atomically:YES encoding:NSUTF8StringEncoding error:nil];
|
||||
NSLog(@"[Pre-Init] File \"%s\" has been migrated", filename);
|
||||
} else {
|
||||
NSDebugLog(@"[Pre-Init] File \"%s\" was already migrated", filename);
|
||||
}
|
||||
}
|
||||
|
||||
void init_redirectStdio() {
|
||||
NSLog(@"[Pre-init] Starting logging STDIO to latestlog.txt\n");
|
||||
|
||||
@@ -246,16 +211,20 @@ void init_setupMultiDir() {
|
||||
}
|
||||
|
||||
const char *home = getenv("POJAV_HOME");
|
||||
NSString *jvmPath = [NSString stringWithFormat:@"%s/java_runtimes", home];
|
||||
NSString *lasmPath = [NSString stringWithFormat:@"%s/Library/Application Support/minecraft", home];
|
||||
NSString *multidirPath = [NSString stringWithFormat:@"%s/instances/%@", home, multidir];
|
||||
NSString *demoPath = [NSString stringWithFormat:@"%s/.demo", home];
|
||||
|
||||
[fm createDirectoryAtPath:jvmPath withIntermediateDirectories:YES attributes:nil error:nil];
|
||||
[fm createDirectoryAtPath:demoPath withIntermediateDirectories:YES attributes:nil error:nil];
|
||||
[fm createDirectoryAtPath:multidirPath withIntermediateDirectories:YES attributes:nil error:nil];
|
||||
|
||||
NSArray *dirsToCreate = @[
|
||||
[NSString stringWithFormat:@"%s/.demo", home],
|
||||
[NSString stringWithFormat:@"%s/java_runtimes", home],
|
||||
lasmPath.stringByDeletingLastPathComponent,
|
||||
multidirPath
|
||||
];
|
||||
for (NSString *dir in dirsToCreate) {
|
||||
[fm createDirectoryAtPath:dir withIntermediateDirectories:YES attributes:nil error:nil];
|
||||
}
|
||||
[fm removeItemAtPath:lasmPath error:nil];
|
||||
[fm createDirectoryAtPath:lasmPath.stringByDeletingLastPathComponent withIntermediateDirectories:YES attributes:nil error:nil];
|
||||
[fm createSymbolicLinkAtPath:lasmPath withDestinationPath:multidirPath error:nil];
|
||||
[fm changeCurrentDirectoryPath:lasmPath];
|
||||
setenv("POJAV_GAME_DIR", lasmPath.UTF8String, 1);
|
||||
@@ -318,7 +287,6 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
setenv("BUNDLE_PATH", dirname(argv[0]), 1);
|
||||
isJailbroken = init_checkForJailbreak();
|
||||
init_migrateDirIfNecessary();
|
||||
init_setupHomeDirectory();
|
||||
init_redirectStdio();
|
||||
init_logDeviceAndVer(argv[0]);
|
||||
@@ -337,9 +305,6 @@ int main(int argc, char *argv[]) {
|
||||
init_setupAccounts();
|
||||
init_setupCustomControls();
|
||||
|
||||
init_migrateToPlist("java.java_args", "overrideargs.txt");
|
||||
init_migrateToPlist("java.env_variables", "custom_env.txt");
|
||||
|
||||
// If sandbox is disabled, W^X JIT can be enabled by PojavLauncher itself
|
||||
if (!isJITEnabled(true) && getEntitlementValue(@"com.apple.private.security.no-sandbox")) {
|
||||
NSLog(@"[Pre-init] no-sandbox: YES, trying to enable JIT");
|
||||
|
||||
@@ -55,12 +55,6 @@ void hooked_exit(int code) {
|
||||
}
|
||||
handle_fatal_exit(code);
|
||||
|
||||
/*
|
||||
if (runtimeJavaVMPtr != NULL) {
|
||||
(*runtimeJavaVMPtr)->DestroyJavaVM(runtimeJavaVMPtr);
|
||||
}
|
||||
*/
|
||||
|
||||
orig_exit(code);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user