[vlc-commits] macosx: disk open: do a shallow instead of a deep search for media directories

David Fuhrmann git at videolan.org
Sun Jun 24 14:13:20 CEST 2012


vlc | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Sun Jun 24 14:09:36 2012 +0200| [d86de10ce6a52c523dc33848b4f36fe22b5a7bb6] | committer: David Fuhrmann

macosx: disk open: do a shallow instead of a deep search for media directories

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d86de10ce6a52c523dc33848b4f36fe22b5a7bb6
---

 modules/gui/macosx/open.m |   44 ++++++++++++++++++++++++++++++++------------
 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/modules/gui/macosx/open.m b/modules/gui/macosx/open.m
index d3f37b8..ea97f78 100644
--- a/modules/gui/macosx/open.m
+++ b/modules/gui/macosx/open.m
@@ -837,21 +837,41 @@ static VLCOpen *_o_sharedMainInstance = nil;
             {
                 // NSFileManager is not thread-safe, don't use defaultManager outside of the main thread
                 NSFileManager * fm = [[NSFileManager alloc] init];
-                NSArray * topLevelItems;
-                topLevelItems = [fm subpathsOfDirectoryAtPath: mountPath error: NULL];
-                [fm release];
 
-                NSUInteger itemCount = [topLevelItems count];
-                for (int i = 0; i < itemCount; i++) {
-                    if([[topLevelItems objectAtIndex:i] rangeOfString:@"SVCD"].location != NSNotFound) {
-                        returnValue = kVLCMediaSVCD;
-                        break;
-                    }
-                    if([[topLevelItems objectAtIndex:i] rangeOfString:@"VCD"].location != NSNotFound) {
-                        returnValue = kVLCMediaVCD;
-                        break;
+                NSArray *dirContents = [fm contentsOfDirectoryAtPath:mountPath error:nil];
+                for (int i = 0; i < [dirContents count]; i++)
+                {
+                    NSString *currentFile = [dirContents objectAtIndex:i];
+                    NSString *fullPath = [mountPath stringByAppendingPathComponent:currentFile];
+
+                    BOOL isDir;
+                    if ([fm fileExistsAtPath:fullPath isDirectory:&isDir] && isDir)
+                    {                        
+                        if ([currentFile caseInsensitiveCompare:@"SVCD"] == NSOrderedSame)
+                        {
+                            returnValue = kVLCMediaSVCD;
+                            break;
+                        }
+                        if ([currentFile caseInsensitiveCompare:@"VCD"] == NSOrderedSame)
+                        {
+                            returnValue = kVLCMediaVCD;
+                            break;
+                        }
+                        if ([currentFile caseInsensitiveCompare:@"BDMV"] == NSOrderedSame)
+                        {
+                            returnValue = kVLCMediaBDMVFolder;
+                            break;
+                        }
+                        if ([currentFile caseInsensitiveCompare:@"VIDEO_TS"] == NSOrderedSame)
+                        {
+                            returnValue = kVLCMediaVideoTSFolder;
+                            break;
+                        }
                     }
                 }
+
+                [fm release];
+
                 if(!returnValue)
                     returnValue = kVLCMediaVideoTSFolder;
             }



More information about the vlc-commits mailing list