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:
faust3 2003-04-18 18:17:05 +00:00
parent 40a073bea4
commit c24c7d909e
1 changed files with 16 additions and 0 deletions

View File

@ -2,11 +2,27 @@
char *get_path(char *filename){ char *get_path(char *filename){
char *homedir; char *homedir;
char *buff; char *buff;
#if defined(__MINGW32__)||defined(__CYGWIN__)
static char *config_dir = "/mplayer";
#else
static char *config_dir = "/.mplayer"; static char *config_dir = "/.mplayer";
#endif
int len; int len;
if ((homedir = getenv("HOME")) == NULL) 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; return NULL;
#endif
len = strlen(homedir) + strlen(config_dir) + 1; len = strlen(homedir) + strlen(config_dir) + 1;
if (filename == NULL) { if (filename == NULL) {
if ((buff = (char *) malloc(len)) == NULL) if ((buff = (char *) malloc(len)) == NULL)