소스 검색

make commit 8b5912bef46c3e836689fd3b2870f44e2a540cb6 work with the new MediaLibrary

Signed-off-by: Felix Paul Kühne <fkuehne@videolan.org>
Carola Nitz 10 년 전
부모
커밋
c14da4e2bf
1개의 변경된 파일16개의 추가작업 그리고 2개의 파일을 삭제
  1. 16 2
      Sources/VLCAppDelegate.m

+ 16 - 2
Sources/VLCAppDelegate.m

@@ -293,12 +293,26 @@
             fileURL = [NSURL fileURLWithPath:filePath];
             [fileURL setResourceValue:@YES forKey:NSURLIsExcludedFromBackupKey error:nil];
         } else {
-
             BOOL isDirectory = NO;
             BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:filePath isDirectory:&isDirectory];
+
             // add folders
             if (exists && isDirectory) {
-                [foundFiles addObjectsFromArray:[[NSFileManager defaultManager] contentsOfDirectoryAtPath:filePath error:nil]];
+                NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:filePath error:nil];
+                for (NSString* file in files) {
+                    NSString *fullFilePath = [directoryPath stringByAppendingPathComponent:file];
+                    isDirectory = NO;
+                    exists = [[NSFileManager defaultManager] fileExistsAtPath:fullFilePath isDirectory:&isDirectory];
+                    //only add folders or files in folders
+                    if ((exists && isDirectory) || ![filePath.lastPathComponent isEqualToString:@"Documents"]) {
+                        NSString *folderpath = [filePath stringByReplacingOccurrencesOfString:directoryPath withString:@""];
+                        if (![folderpath isEqualToString:@""]) {
+                            folderpath = [folderpath stringByAppendingString:@"/"];
+                        }
+                        NSString *path = [folderpath stringByAppendingString:file];
+                        [foundFiles addObject:path];
+                    }
+                }
             }
         }
     }