diff options
author | nplourde <nplourde@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2005-06-03 14:52:15 +0000 |
---|---|---|
committer | nplourde <nplourde@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2005-06-03 14:52:15 +0000 |
commit | fc2cce6462e600fea58de327579fcadeb03cfd8c (patch) | |
tree | a4e7582c1e599ac9f8515c19d8c5a2eb3af9d4ce /get_path.c | |
parent | 241c16ceec6656cddcc6f7b1809fdfad367a8e47 (diff) | |
download | mpv-fc2cce6462e600fea58de327579fcadeb03cfd8c.tar.bz2 mpv-fc2cce6462e600fea58de327579fcadeb03cfd8c.tar.xz |
compare resource url with bundle url, if its the same path do not use has conf file location.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15626 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'get_path.c')
-rw-r--r-- | get_path.c | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/get_path.c b/get_path.c index c9b80d4f6d..bde2b79fc2 100644 --- a/get_path.c +++ b/get_path.c @@ -29,6 +29,11 @@ char *get_path(char *filename){ int len; #ifdef MACOSX_BUNDLE struct stat dummy; + CFIndex maxlen=256; + CFURLRef res_url_ref=NULL; + CFURLRef bdl_url_ref=NULL; + char *res_url_path = NULL; + char *bdl_url_path = NULL; #endif if ((homedir = getenv("HOME")) == NULL) @@ -58,30 +63,39 @@ char *get_path(char *filename){ #ifdef MACOSX_BUNDLE if(stat(buff, &dummy)) { - CFIndex maxlen=64; - CFURLRef resources=NULL; - free(buff); - buff=NULL; + res_url_ref=CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); + bdl_url_ref=CFBundleCopyBundleURL(CFBundleGetMainBundle()); - resources=CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); - if(resources) { + if(res_url_ref&&bdl_url_ref) { - buff=malloc(maxlen); - *buff=0; - - while(!CFURLGetFileSystemRepresentation(resources, true, buff, maxlen)) { + res_url_path=malloc(maxlen); + bdl_url_path=malloc(maxlen); + + while(!CFURLGetFileSystemRepresentation(res_url_ref, true, res_url_path, maxlen)) { + maxlen*=2; + res_url_path=realloc(res_url_path, maxlen); + } + CFRelease(res_url_ref); + + while(!CFURLGetFileSystemRepresentation(bdl_url_ref, true, bdl_url_path, maxlen)) { maxlen*=2; - buff=realloc(buff, maxlen); + bdl_url_path=realloc(bdl_url_path, maxlen); } - CFRelease(resources); + CFRelease(bdl_url_ref); + + if( strcmp(res_url_path, bdl_url_path) == 0) + res_url_path = NULL; } - if(buff&&filename) { - if((strlen(filename)+strlen(buff)+2)>maxlen) { - maxlen=strlen(filename)+strlen(buff)+2; - buff=realloc(buff, maxlen); + if(res_url_path&&filename) { + if((strlen(filename)+strlen(res_url_path)+2)>maxlen) { + maxlen=strlen(filename)+strlen(res_url_path)+2; } + free(buff); + buff = (char *) malloc(maxlen); + strcpy(buff, res_url_path); + strcat(buff,"/"); strcat(buff, filename); } |