From cda33f62f781d59d68594906206372e5b27c70f8 Mon Sep 17 00:00:00 2001 From: Pierre d'Herbemont <pdherbemont@videolan.org> Date: Wed, 5 Sep 2007 18:45:09 +0000 Subject: [PATCH] misc/darwin_specific.c: Correctly detect the Mac OS X framework. --- src/misc/darwin_specific.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/misc/darwin_specific.c b/src/misc/darwin_specific.c index 69695c8e143d..453f12e84117 100644 --- a/src/misc/darwin_specific.c +++ b/src/misc/darwin_specific.c @@ -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 ; ) -- GitLab