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

David Fuhrmann git at videolan.org
Wed Jun 27 20:08:17 CEST 2012


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

macosx: disk open: do a shallow instead of a deep search for media directories
(cherry picked from commit d86de10ce6a52c523dc33848b4f36fe22b5a7bb6)

Signed-off-by: David Fuhrmann <david.fuhrmann at googlemail.com>

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

 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 d08bc53..6fda36e 100644
--- a/modules/gui/macosx/open.m
+++ b/modules/gui/macosx/open.m
@@ -767,21 +767,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