2001-10-30 17:04:59 +00:00
|
|
|
|
|
|
|
char *get_path(char *filename){
|
|
|
|
char *homedir;
|
|
|
|
char *buff;
|
2003-04-30 18:16:21 +00:00
|
|
|
#if defined(__MINGW32__)
|
2003-04-18 18:17:05 +00:00
|
|
|
static char *config_dir = "/mplayer";
|
|
|
|
#else
|
2001-10-30 17:04:59 +00:00
|
|
|
static char *config_dir = "/.mplayer";
|
2003-04-18 18:17:05 +00:00
|
|
|
#endif
|
2001-10-30 17:04:59 +00:00
|
|
|
int len;
|
|
|
|
|
|
|
|
if ((homedir = getenv("HOME")) == NULL)
|
2003-04-18 18:17:05 +00:00
|
|
|
#if defined(__MINGW32__)||defined(__CYGWIN__) /*hack to get fonts etc. loaded outside of cygwin environment*/
|
|
|
|
{
|
|
|
|
int __stdcall GetModuleFileNameA(void* hModule,char* lpFilename,int nSize);
|
|
|
|
int i,imax=0;
|
2003-04-18 20:11:36 +00:00
|
|
|
char exedir[260];
|
|
|
|
GetModuleFileNameA(NULL, exedir, 260);
|
2003-04-18 18:17:05 +00:00
|
|
|
for(i=0; i< strlen(exedir);i++)if(exedir[i] =='\\'){exedir[i]='/';imax=i;}
|
|
|
|
exedir[imax]='\0';
|
|
|
|
homedir = exedir;
|
|
|
|
}
|
|
|
|
#else
|
2001-10-30 17:04:59 +00:00
|
|
|
return NULL;
|
2003-04-18 18:17:05 +00:00
|
|
|
#endif
|
2001-10-30 17:04:59 +00:00
|
|
|
len = strlen(homedir) + strlen(config_dir) + 1;
|
|
|
|
if (filename == NULL) {
|
|
|
|
if ((buff = (char *) malloc(len)) == NULL)
|
|
|
|
return NULL;
|
|
|
|
sprintf(buff, "%s%s", homedir, config_dir);
|
|
|
|
} else {
|
|
|
|
len += strlen(filename) + 1;
|
|
|
|
if ((buff = (char *) malloc(len)) == NULL)
|
|
|
|
return NULL;
|
|
|
|
sprintf(buff, "%s%s/%s", homedir, config_dir, filename);
|
|
|
|
}
|
2001-12-25 20:41:04 +00:00
|
|
|
mp_msg(MSGT_GLOBAL,MSGL_V,"get_path('%s') -> '%s'\n",filename,buff);
|
2001-10-30 17:04:59 +00:00
|
|
|
return buff;
|
|
|
|
}
|