From 0b42688f746c661d07253a0dcfad4a23440259c6 Mon Sep 17 00:00:00 2001 From: khanhduytran0 Date: Tue, 13 Aug 2024 21:53:10 +0700 Subject: [PATCH] #118 --- main.m | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.m b/main.m index b3cc8d4..67dfd66 100644 --- a/main.m +++ b/main.m @@ -239,11 +239,16 @@ static void overwriteExecPath(NSString *bundlePath) { NSProcessInfo.processInfo.processName = appBundle.infoDictionary[@"CFBundleExecutable"]; *_CFGetProgname() = NSProcessInfo.processInfo.processName.UTF8String; - // Overwrite home path + // Overwrite home and tmp path NSString *newHomePath = [NSString stringWithFormat:@"%@/Data/Application/%@", docPath, appBundle.infoDictionary[@"LCDataUUID"]]; + NSString *newTmpPath = [newHomePath stringByAppendingPathComponent:@"tmp"]; + remove(newTmpPath.UTF8String); + symlink(getenv("TMPDIR"), newTmpPath.UTF8String); + setenv("CFFIXED_USER_HOME", newHomePath.UTF8String, 1); setenv("HOME", newHomePath.UTF8String, 1); - setenv("TMPDIR", [@(getenv("TMPDIR")) stringByAppendingFormat:@"%@/tmp/", appBundle.infoDictionary[@"LCDataUUID"]].UTF8String, 1); + setenv("TMPDIR", newTmpPath.UTF8String, 1); + // Setup directories NSArray *dirList = @[@"Library/Caches", @"Documents", @"SystemData"]; for (NSString *dir in dirList) {