瀏覽代碼

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];
+                    }
+                }
             }
         }
     }