save default configuration file on first run without conf file

This commit is contained in:
Julien Danjou 2007-12-13 11:04:48 +01:00
parent 5f811b1cf2
commit ecf6f6ebbb

View file

@ -305,6 +305,7 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
ssize_t confpath_len;
Key *key = NULL;
Rule *rule = NULL;
FILE *defconfig = NULL;
if(confpatharg)
confpath = a_strdup(confpatharg);
@ -327,6 +328,8 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
{
perror("awesome: parsing configuration file failed");
cfg_parse_buf(cfg, AWESOME_DEFAULT_CONFIG);
if(!(defconfig = fopen(confpath, "w")))
perror("awesome: unable to create default configuration file");
}
else if(ret == CFG_PARSE_ERROR)
cfg_error(cfg, "awesome: parsing configuration file %s failed.\n", confpath);
@ -528,6 +531,12 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
else
awesomeconf->keys = NULL;
if(defconfig)
{
cfg_print(cfg, defconfig);
fclose(defconfig);
}
/* Free! Like a river! */
cfg_free(cfg);
p_delete(&confpath);