3 * Get path to config dir/file.
6 * Returns the pointer to the ALLOCATED buffer containing the
7 * zero terminated path string. This buffer has to be FREED
11 char *get_path(char *filename
){
14 #if defined(__MINGW32__)
15 static char *config_dir
= "/mplayer";
17 static char *config_dir
= "/.mplayer";
21 if ((homedir
= getenv("HOME")) == NULL
)
22 #if defined(__MINGW32__)||defined(__CYGWIN__) /*hack to get fonts etc. loaded outside of cygwin environment*/
26 GetModuleFileNameA(NULL
, exedir
, 260);
27 for(i
=0; i
< strlen(exedir
);i
++)if(exedir
[i
] =='\\'){exedir
[i
]='/';imax
=i
;}
34 len
= strlen(homedir
) + strlen(config_dir
) + 1;
35 if (filename
== NULL
) {
36 if ((buff
= (char *) malloc(len
)) == NULL
)
38 sprintf(buff
, "%s%s", homedir
, config_dir
);
40 len
+= strlen(filename
) + 1;
41 if ((buff
= (char *) malloc(len
)) == NULL
)
43 sprintf(buff
, "%s%s/%s", homedir
, config_dir
, filename
);
45 mp_msg(MSGT_GLOBAL
,MSGL_V
,"get_path('%s') -> '%s'\n",filename
,buff
);