From 55adc096e1d1267a200b6eb2479076aa4bdc834d Mon Sep 17 00:00:00 2001 From: nplourde Date: Wed, 13 Apr 2005 11:46:35 +0000 Subject: allows the Mac OS X version of MPlayer to look for its data files inside the Resources directory of the appwrapper. patch by Chris Roccati git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15146 b3059339-0415-0410-9bf9-f77b7e298cf2 --- configure | 18 ++++++++++++++++++ get_path.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/configure b/configure index 2e9484c75f..e2f0469335 100755 --- a/configure +++ b/configure @@ -185,6 +185,7 @@ Optional features: --disable-enca Disable using ENCA charset oracle library [autodetect] --disable-macosx Disable Mac OS X specific features [autodetect] --enable-macosx-finder-support Enable Mac OS X Finder invocation parameter parsing [disabled] + --enable-macosx-bundle Enable Mac OS X bundle file locations [autodetect] --disable-inet6 Disable IPv6 support [autodetect] --disable-gethostbyname2 gethostbyname() function is not provided by the C library [autodetect] @@ -1400,6 +1401,7 @@ _menu=no _qtx=auto _macosx=auto _macosx_finder_support=no +_macosx_bundle=auto _sortsub=yes _freetypeconfig='freetype-config' _fribidi=no @@ -1684,6 +1686,8 @@ for ac_option do --disable-macosx) _macosx=no ;; --enable-macosx-finder-support) _macosx_finder_support=yes ;; --disable-macosx-finder-support) _macosx_finder_support=no ;; + --enable-macosx-bundle) _macosx_bundle=yes;; + --disable-macosx-bundle) _macosx_bundle=no;; --enable-sortsub) _sortsub=yes ;; --disable-sortsub) _sortsub=no ;; @@ -3208,6 +3212,18 @@ else fi echores "$_macosx_finder_support" +echocheck "Mac OS X Bundle file locations" +if test "$_macosx_bundle" = auto ; then + _macosx_bundle=$_macosx_finder_support +fi +if test "$_macosx_bundle" = yes; then + _def_macosx_bundle='#define MACOSX_BUNDLE 1' +else + _def_macosx_bundle='#undef MACOSX_BUNDLE' + _macosx_bundle=no +fi +echores "$_macosx_bundle" + echocheck "Samba support (libsmbclient)" if test "$_smbsupport" = yes; then _ld_smb="-lsmbclient" @@ -6824,6 +6840,7 @@ XMMS_PLUGINS = $_xmms XMMS_LIB = $_xmms_lib MACOSX = $_macosx MACOSX_FINDER_SUPPORT = $_macosx_finder_support +MACOSX_BUNDLE = $_macosx_bundle MACOSX_FRAMEWORKS = $_macosx_frameworks TOOLAME=$_toolame TOOLAME_EXTRAFLAGS=$_toolame_extraflags @@ -7131,6 +7148,7 @@ $_def_dshow /* Mac OS X specific features */ $_def_macosx $_def_macosx_finder_support +$_def_macosx_bundle /* Build our Win32-loader */ $_def_win32_loader diff --git a/get_path.c b/get_path.c index 0cd6529773..6443f33e6c 100644 --- a/get_path.c +++ b/get_path.c @@ -8,6 +8,16 @@ * by the caller. * */ +#ifdef MACOSX_BUNDLE +#include +#include +#include +#include +#include +#include +#include +#endif + char *get_path(char *filename){ char *homedir; char *buff; @@ -17,6 +27,9 @@ char *get_path(char *filename){ static char *config_dir = "/.mplayer"; #endif int len; +#ifdef MACOSX_BUNDLE + struct stat dummy; +#endif if ((homedir = getenv("HOME")) == NULL) #if defined(__MINGW32__)||defined(__CYGWIN__) /*hack to get fonts etc. loaded outside of cygwin environment*/ @@ -42,6 +55,38 @@ char *get_path(char *filename){ return NULL; sprintf(buff, "%s%s/%s", homedir, config_dir, filename); } + +#ifdef MACOSX_BUNDLE + if(stat(buff, &dummy)) { + CFIndex maxlen=64; + CFURLRef resources=NULL; + + free(buff); + buff=NULL; + + resources=CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); + if(resources) { + + buff=malloc(maxlen); + *buff=0; + + while(!CFURLGetFileSystemRepresentation(resources, true, buff, maxlen)) { + maxlen*=2; + buff=realloc(buff, maxlen); + } + CFRelease(resources); + } + + if(buff&&filename) { + if((strlen(filename)+strlen(buff)+2)>maxlen) { + maxlen=strlen(filename)+strlen(buff)+2; + buff=realloc(buff, maxlen); + } + strcat(buff,"/"); + strcat(buff, filename); + } + } +#endif mp_msg(MSGT_GLOBAL,MSGL_V,"get_path('%s') -> '%s'\n",filename,buff); return buff; } -- cgit v1.2.3