我正在尝试编写一些代码来检查或更改(并非恶意)用户设备上安装的其他iOS应用程序,特别是越狱设备。在越狱设备上,我能够查看应用程序沙盒外的文件,当我使用NSFileManager查看“/private/var/mobile/Applications/”时,我看到了一系列以十六进制方案命名的目录,正如所预期的那样。
不幸的是,当我查看每个目录时,除了运行的应用程序本身之外,它们都返回isDirectory为FALSE,并且attributesOfItemAtPath为NULL。我需要访问每个文件夹中的.app,但我无法查看它们的下层内容,每个目录都返回无效信息。
以下是我正在使用的代码:
不幸的是,当我查看每个目录时,除了运行的应用程序本身之外,它们都返回isDirectory为FALSE,并且attributesOfItemAtPath为NULL。我需要访问每个文件夹中的.app,但我无法查看它们的下层内容,每个目录都返回无效信息。
以下是我正在使用的代码:
NSString *path = @"/private/var/mobile/Applications/";
NSFileManager *manager = [NSFileManager defaultManager];
NSArray *fileList = [manager contentsOfDirectoryAtPath:path error:nil];
for(NSString *file in fileList) {
NSString *fullpath = [path stringByAppendingPathComponent:file];
NSLog(@"fullpath = %@", fullpath);
BOOL isDir = nil;
[manager fileExistsAtPath:fullpath isDirectory:(&isDir)];
if(isDir) {
NSLog(@"isDir");
//NSArray *subfiles = [self filesBeneathDirectory:fullpath withExtension:extension];
} else {
NSLog(@"!isDir");
NSDictionary *attributes = [manager attributesOfItemAtPath:fullpath error:nil];
NSLog(@"attributes = %@",attributes);
}
}
我希望能够在这些目录下检测到文件,因为我的iPhone已经越狱并具有完整的root访问权限。