Mon, 12 Aug 2013 14:55:31 +0200
creates an empty configuration file if needed
dav/config.c | file | annotate | diff | comparison | revisions |
--- a/dav/config.c Mon Aug 12 14:40:19 2013 +0200 +++ b/dav/config.c Mon Aug 12 14:55:31 2013 +0200 @@ -46,6 +46,15 @@ char *file = util_concat_path(getenv("HOME"), ".dav/config.xml"); xmlDoc *doc = xmlReadFile(file, NULL, 0); + if(!doc) { + doc = xmlNewDoc(BAD_CAST "1.0"); + xmlNode *root = xmlNewNode(NULL, BAD_CAST "configuration"); + xmlDocSetRootElement(doc, root); + xmlSaveFormatFileEnc(file, doc, "UTF-8", 1); + xmlFreeDoc(doc); + free(file); + return; + } free(file); xmlNode *xml_root = xmlDocGetRootElement(doc);