[MPlayer-cvslog] CVS: main get_path.c,1.7,1.8
Nicolas Plourde CVS
syncmail at mplayerhq.hu
Wed Apr 13 13:46:14 CEST 2005
CVS change done by Nicolas Plourde CVS
Update of /cvsroot/mplayer/main
In directory mail:/var2/tmp/cvs-serv20501
Modified Files:
get_path.c
Log Message:
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 <roccati at pobox.com>
Index: get_path.c
===================================================================
RCS file: /cvsroot/mplayer/main/get_path.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- get_path.c 23 Jul 2004 16:35:20 -0000 1.7
+++ get_path.c 13 Apr 2005 11:46:12 -0000 1.8
@@ -8,6 +8,16 @@
* by the caller.
*
*/
+#ifdef MACOSX_BUNDLE
+#include <Carbon/Carbon.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#endif
+
char *get_path(char *filename){
char *homedir;
char *buff;
@@ -17,6 +27,9 @@
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 @@
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;
}
More information about the MPlayer-cvslog
mailing list