From 6d307587eb551bab031667b771140a673fe1939e Mon Sep 17 00:00:00 2001 From: khanhduytran0 Date: Thu, 25 Apr 2024 20:40:54 +0700 Subject: [PATCH] Ensure critical dirs exist before starting guest app --- main.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.m b/main.m index cdb6b6c..df20da3 100644 --- a/main.m +++ b/main.m @@ -243,8 +243,11 @@ static void overwriteExecPath(NSString *bundlePath) { setenv("HOME", newHomePath.UTF8String, 1); setenv("TMPDIR", [@(getenv("TMPDIR")) stringByAppendingFormat:@"/%@/tmp", appBundle.infoDictionary[@"LCDataUUID"]].UTF8String, 1); // Setup directories - NSString *cachePath = [NSString stringWithFormat:@"%@/Library/Caches", newHomePath]; - [fm createDirectoryAtPath:cachePath withIntermediateDirectories:YES attributes:nil error:nil]; + NSArray *dirList = @[@"Library/Caches", @"Documents", @"SystemData"]; + for (NSString *dir in dirList) { + NSString *dirPath = [newHomePath stringByAppendingPathComponent:dir]; + [fm createDirectoryAtPath:dirPath withIntermediateDirectories:YES attributes:nil error:nil]; + } // Preload executable to bypass RT_NOLOAD uint32_t appIndex = _dyld_image_count();