iphone - NSFileManager 无法查看某些目录下的内容

标签 iphone ios jailbreak nsfilemanager

我正在尝试编写一些代码来检查或更改(不是恶意或类似的)用户设备上安装的其他 iOS 应用程序。特别是在越狱设备上。在越狱设备上,我能够查看应用程序沙箱之外的文件,当我使用 NSFileManager 查看“/private/var/mobile/Applications/”时,我会看到目录列表(以某种十六进制方案命名) 。正如预期的那样。

不幸的是,当我查看每个目录时,它们都返回(除了正在运行的应用程序本身)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 访问权限(作为越狱设备等等)。

最佳答案

从您的应用程序中,您只能访问您自己的沙箱。如果您访问其他目录中的文件,这不会有任何好处,Apple 限制访问有一些很好的理由。

关于iphone - NSFileManager 无法查看某些目录下的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6274532/

相关文章:

ios - Siren库如何获取当前的应用商店版本?

objective-c - 如何在 iOS 6.x 中以静默方式在后台启动应用程序

iphone - 为 Cydia 开发应用程序

iphone - 使应用程序在后台无限制地保持事件状态(对于 Cydia 应用程序)

iphone - Xcode 7.1 执行调试时总是崩溃

ios - iOS中pod install命令的工作流程

ios - iPhone 6 和 6 plus 屏幕像素大小?

ios - UITableViewCell 中的 UIButton 不显示 textLabel 更改,直到单元格滚出屏幕

ios - SKSpriteNode zrotation M_PI真气人

iphone - AVAudioRecorder 更改录制的音高