]> git.sesse.net Git - vlc/commitdiff
misc/darwin_specific.c: Correctly detect the Mac OS X framework.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Wed, 5 Sep 2007 18:45:09 +0000 (18:45 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Wed, 5 Sep 2007 18:45:09 +0000 (18:45 +0000)
src/misc/darwin_specific.c

index 69695c8e143d92b8c19aa38acea81408fd687ae8..453f12e841170640725216f8ddee694462f5ef67 100644 (file)
@@ -67,9 +67,25 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, char *ppsz_argv[] )
 {
     char i_dummy;
     char *p_char, *p_oldchar = &i_dummy;
+       int i;
 
     /* Get the full program path and name */
-    p_char = vlc_global()->psz_vlcpath = strdup( ppsz_argv[ 0 ] );
+
+    /* First try to see if we are linked to the framework */
+    for (i = 0; i < _dyld_image_count(); i++)
+    {
+        char * psz_img_name = _dyld_get_image_name(i);
+        if( !strstr( psz_img_name, "VLC.framework/Version/Current/Framework/VLC" ) )
+            p_char = strdup( psz_img_name );
+    }
+
+    if( !p_char )
+    {
+        /* We are not linked to the VLC.framework, return the executable path */
+        p_char = strdup( ppsz_argv[ 0 ] );
+    }
+
+       vlc_global()->psz_vlcpath = p_char;
 
     /* Remove trailing program name */
     for( ; *p_char ; )