--- mencoder.c_bak 2007-11-19 11:11:53.000000000 -0500 +++ mencoder.c 2007-11-19 11:36:18.000000000 -0500 @@ -43,6 +43,7 @@ #include "cpudetect.h" +#include "cfg-mplayer-def.h" #include "codec-cfg.h" #include "m_option.h" #include "m_config.h" @@ -319,12 +320,30 @@ static void parse_cfgfiles( m_config_t* conf ) { char *conffile; - if ((conffile = get_path("mencoder.conf")) == NULL) { - mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_GetpathProblem); + int conffile_fd; + if (m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mencoder.conf") < 0) + mencoder_exit(1,MSGTR_ConfigFileError); + if ((conffile = get_path("")) == NULL) { + mp_msg(MSGT_CPLAYER,MSGL_WARN,MSGTR_NoHomeDir); } else { - if (m_config_parse_config_file(conf, conffile) < 0) - mencoder_exit(1,MSGTR_ConfigFileError); +#ifdef __MINGW32__ + mkdir(conffile); +#else + mkdir(conffile, 0777); +#endif free(conffile); + if ((conffile = get_path("mencoder.conf")) == NULL) { + mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_GetpathProblem); + } else { + if ((conffile_fd = open(conffile, O_CREAT|O_EXCL|O_WRONLY, 0666)) != -1) { + mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_CreatingCfgFile, conffile); + write(conffile_fd, default_config, strlen(default_config)); + close(conffile_fd); + } + if (m_config_parse_config_file(conf, conffile) < 0) + mencoder_exit(1,MSGTR_ConfigFileError); + free(conffile); + } } }