mirror of https://github.com/mpv-player/mpv
allow config file loading outside of cygwin environment
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9927 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
40a073bea4
commit
c24c7d909e
16
get_path.c
16
get_path.c
|
@ -2,11 +2,27 @@
|
|||
char *get_path(char *filename){
|
||||
char *homedir;
|
||||
char *buff;
|
||||
#if defined(__MINGW32__)||defined(__CYGWIN__)
|
||||
static char *config_dir = "/mplayer";
|
||||
#else
|
||||
static char *config_dir = "/.mplayer";
|
||||
#endif
|
||||
int len;
|
||||
|
||||
if ((homedir = getenv("HOME")) == NULL)
|
||||
#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;
|
||||
char exedir[MAX_PATH];
|
||||
GetModuleFileNameA(NULL, exedir, MAX_PATH);
|
||||
for(i=0; i< strlen(exedir);i++)if(exedir[i] =='\\'){exedir[i]='/';imax=i;}
|
||||
exedir[imax]='\0';
|
||||
homedir = exedir;
|
||||
}
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
len = strlen(homedir) + strlen(config_dir) + 1;
|
||||
if (filename == NULL) {
|
||||
if ((buff = (char *) malloc(len)) == NULL)
|
||||
|
|
Loading…
Reference in New Issue