Skip to content

Commit

Permalink
Change how tmp files are stored
Browse files Browse the repository at this point in the history
To provide maximum compatibility, now guest app's tmp folder is just a symlink to that of LiveContainer.
  • Loading branch information
khanhduytran0 committed Aug 14, 2024
1 parent 99b0c31 commit 7d0facc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main.m
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7d0facc

Please sign in to comment.