0

Im trying to check if a file exists at /var/mobile/Documents/ and it works perfectly on devices that aren't arm64. But when I try it on an arm64 device it's giving me cocoa error 257.

I tried on ipad3/4 and ipod5 and it worked. But when I tried it on both ipad mini 2 and iPhone5S they both gave me cocoa error 257.

I did a quick check to see if the file is readable and I get YES on ipad3/4 and ipod5 but I get NO on ipad mini 2 and 5S.

if ([[NSFileManager defaultManager] isReadableFileAtPath:@"/var/mobile/Documents/"]  == YES) {
          UIAlertView *al = [[UIAlertView alloc] initWithTitle:@"yes" message:nil delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
          [al show];
} else {
           UIAlertView *al = [[UIAlertView alloc] initWithTitle:@"no" message:nil delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
           [al show];
}

Any help would be appreciated!

Mike
  • 59
  • 1
  • 1
  • 5
  • What happens when you make the same call for `/var/mobile`? – mharper Mar 29 '14 at 18:30
  • @mharper Same thing happens, and it all seems to work if I call for /var/ but stops working on arm64 when I call /var/mobile/ or anything inside mobile. – Mike Mar 29 '14 at 18:31
  • See @igor's answer. `NSSearchPathForDirectoriesInDomains` must return a different path depending on the architecture. – mharper Mar 29 '14 at 18:39

1 Answers1

1
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = paths[0];

if([[NSFileManager defaultManager] isReadableFileAtPath:documentsDirectoryPath]) {
    UIAlertView *al = [[UIAlertView alloc] initWithTitle:@"yes"
                                                 message:nil
                                                delegate:self
                                       cancelButtonTitle:@"Ok"
                                       otherButtonTitles:nil, nil];
    [al show];
}
else {
    UIAlertView *al = [[UIAlertView alloc] initWithTitle:@"no"
                                                 message:nil
                                                delegate:self
                                       cancelButtonTitle:@"Ok"
                                       otherButtonTitles:nil, nil];
    [al show];
}
Igor Matyushkin
  • 778
  • 4
  • 4