Pārlūkot izejas kodu

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

Carola Nitz 7 gadi atpakaļ
vecāks
revīzija
601bacfd22
1 mainītis faili ar 10 papildinājumiem un 3 dzēšanām
  1. 10 3
      Sources/VLCHTTPConnection.m

+ 10 - 3
Sources/VLCHTTPConnection.m

@@ -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