dav/scfg.c

changeset 253
1d2be1b31e70
parent 252
6b8e287269fc
child 254
d7c4ba50b7d8
equal deleted inserted replaced
252:6b8e287269fc 253:1d2be1b31e70
56 static UcxMap *directories; 56 static UcxMap *directories;
57 57
58 static int create_default_sync_config(char *file) { 58 static int create_default_sync_config(char *file) {
59 FILE *out = fopen(file, "w"); 59 FILE *out = fopen(file, "w");
60 if(!out) { 60 if(!out) {
61 perror("fopen"); 61 perror("Cannot create config file");
62 return -1; 62 return -1;
63 } 63 }
64 64
65 fputs("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n", out); 65 fputs("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n", out);
66 fputs("<configuration>\n", out); 66 fputs("<configuration>\n", out);
78 struct stat s; 78 struct stat s;
79 if(stat(file, &s)) { 79 if(stat(file, &s)) {
80 switch(errno) { 80 switch(errno) {
81 case ENOENT: { 81 case ENOENT: {
82 if(create_default_sync_config(file)) { 82 if(create_default_sync_config(file)) {
83 /* this recursion is safe: ENOENT cannot occur again */ 83 return 1;
84 return load_sync_config();
85 } 84 }
86 break; 85 break;
87 } 86 }
88 default: { 87 default: {
89 perror("Cannot load sync.xml"); 88 perror("Cannot load sync.xml");

mercurial