Commit 601bacfd authored by Carola Nitz's avatar Carola Nitz

adjusted the filepath check to not crash under iOS7 and return no in case of errors

parent 50035adc
Pipeline #109 failed with stage
in 0 seconds
......@@ -108,14 +108,21 @@
- (BOOL)fileIsInDocumentFolder:(NSString*)filepath
{
if (!filepath) return NO;
NSError *error;
NSURLRelationship relationship;
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *directoryPath = [searchPaths firstObject];
[[NSFileManager defaultManager] getRelationship:&relationship ofDirectoryAtURL:[NSURL fileURLWithPath:directoryPath] toItemAtURL:[NSURL fileURLWithPath:filepath] error:&error];
return relationship == NSURLRelationshipContains;
NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:&error];
if (error != nil) {
APLog(@"checking filerelationship failed %@", error);
return NO;
}
return [array containsObject:filepath.lastPathComponent];
}
#if TARGET_OS_IOS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment