需求:清除某一个app路径下的 /Documents, /Library, /tmp, /StoreKit
深夜福利!越狱iOS清痕暨■■■■■■■■核心代码の无料放送
感谢狗神的分享
我模仿狗神分享的代码进行清除,发现 [fileManager removeItemAtPath:[NSString stringWithFormat:@"/var/mobile/Applications/%@", file] error:nil];
返回0 ,后打开iFile查看 /var/mobile/Applications/
路径下是空的 ,然后百度找到了正确的路径,原来在iOS 8以后路径变为 /var/mobile/Containers/Data/Application/
,后运行代码清除了所有app的 /Documents, /Library, /tmp, /StoreKit 下的东西。
附修改后的代码:
NSFileManager *fileManager = [NSFileManager defaultManager];
NSDirectoryEnumerator *dirEnum = [fileManager enumeratorAtPath:@"/var/mobile/Containers/Data/Application/"];
NSString *file;
while ((file = [dirEnum nextObject]))
if ([file hasSuffix:@"/Documents"] || [file hasSuffix:@"/Library"] || [file hasSuffix:@"/tmp"] || [file hasSuffix:@"/StoreKit"])
{
[fileManager removeItemAtPath:[NSString stringWithFormat:@"/var/mobile/Containers/Data/Application/%@", file] error:nil];
[fileManager createDirectoryAtPath:[NSString stringWithFormat:@"/var/mobile/Containers/Data/Application/%@", file] withIntermediateDirectories:NO attributes:[NSDictionary dictionaryWithObjectsAndKeys:@"mobile", NSFileOwnerAccountName, @"mobile", NSFileGroupOwnerAccountName, nil] error:nil];
}
`
我用iFile查看 /var/mobile/Containers/Data/Application/路径下都是一些如"1FDEAXXXXXXX"的文件名,比如我要删除微信的/Documents, /Library, /tmp, /StoreKit 我不知道它是哪个?所以我想知道怎么才能知道这些文件是哪一个app的路径,想了很久没有思路,我查资料好像这些路径,如果打开app 后是会重新生成的。
环境:iPhone 10.2 安装是使用的Cydia 我发布到威锋源上的