1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-15 19:35:49 +00:00
mpv/get_path.c
diego c36a1c25ba Cygwin should behave like a Unix environment, i.e. config files should be
in .mplayer.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10027 b3059339-0415-0410-9bf9-f77b7e298cf2
2003-04-30 18:16:21 +00:00

40 lines
1.1 KiB
C

char *get_path(char *filename){
char *homedir;
char *buff;
#if defined(__MINGW32__)
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[260];
GetModuleFileNameA(NULL, exedir, 260);
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)
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);
}
mp_msg(MSGT_GLOBAL,MSGL_V,"get_path('%s') -> '%s'\n",filename,buff);
return buff;
}