@@ -513,23 +513,23 @@ - (void)_setEntryCount:(NSInteger)entryCount {
513513// accessible and when you try to use that data. Sidestep this issue altogether
514514// by using NSFileProtectionNone
515515- (BOOL )canAccessEntryData {
516- BOOL result = YES ;
517- if ([_fileDataProtectionMode isEqualToString: NSFileProtectionComplete ]) {
518- result = [[UIApplication sharedApplication ] isProtectedDataAvailable ];
519- } else if ([_fileDataProtectionMode isEqualToString: NSFileProtectionCompleteUntilFirstUserAuthentication ]) {
520- // For "complete until first auth", if we were previously able to access data, then we'll still be able to
521- // access it. If we haven't yet been able to access data, we'll need to try until we are successful.
522- if (_canAccessData == NO ) {
523- if ([[UIApplication sharedApplication ] isProtectedDataAvailable ]) {
524- // we are unlocked, so we're good to go.
525- _canAccessData = YES ;
526- } else {
527- // we are locked, so try to access data.
528- _canAccessData = [NSData dataWithContentsOfURL: [NSURL fileURLWithPath: _filePath] options: NSDataReadingMappedAlways error: NULL ] != nil ;
529- }
530- }
516+ if ([_fileDataProtectionMode isEqualToString: NSFileProtectionNone ])
517+ return YES ;
518+
519+ if ([_fileDataProtectionMode isEqualToString: NSFileProtectionCompleteUntilFirstUserAuthentication ] && _canAccessData)
520+ return YES ;
521+
522+ UIApplication *application = [UIApplication performSelector: @selector (sharedApplication )];
523+ if (application) {
524+ _canAccessData = [application isProtectedDataAvailable ];
525+ } else {
526+ int fd;
527+ _canAccessData = ((fd = open ([_filePath fileSystemRepresentation ], O_RDONLY)) != -1 );
528+ if (_canAccessData)
529+ close (fd);
531530 }
532- return result;
531+
532+ return _canAccessData;
533533}
534534
535535- (FICImageTableEntry *)_entryDataAtIndex : (NSInteger )index {
0 commit comments