86 } |
87 } |
87 |
88 |
88 int scfg_load_directory(xmlNode *node) { |
89 int scfg_load_directory(xmlNode *node) { |
89 char *name = NULL; |
90 char *name = NULL; |
90 char *path = NULL; |
91 char *path = NULL; |
|
92 char *trash = NULL; |
91 char *collection = NULL; |
93 char *collection = NULL; |
92 char *repository = NULL; |
94 char *repository = NULL; |
93 char *database = NULL; |
95 char *database = NULL; |
94 UcxList *include = NULL; |
96 UcxList *include = NULL; |
95 UcxList *exclude = NULL; |
97 UcxList *exclude = NULL; |
102 // next |
104 // next |
103 } else if(xstreq(node->name, "name")) { |
105 } else if(xstreq(node->name, "name")) { |
104 name = value; |
106 name = value; |
105 } else if(xstreq(node->name, "path")) { |
107 } else if(xstreq(node->name, "path")) { |
106 path = value; |
108 path = value; |
|
109 } else if(xstreq(node->name, "trash")) { |
|
110 trash = value; |
107 } else if(xstreq(node->name, "collection")) { |
111 } else if(xstreq(node->name, "collection")) { |
108 collection = value; |
112 collection = value; |
109 } else if(xstreq(node->name, "repository")) { |
113 } else if(xstreq(node->name, "repository")) { |
110 repository = value; |
114 repository = value; |
111 } else if(xstreq(node->name, "database")) { |
115 } else if(xstreq(node->name, "database")) { |
154 } else { |
158 } else { |
155 regex_t *matchnothing = malloc(sizeof(regex_t)); |
159 regex_t *matchnothing = malloc(sizeof(regex_t)); |
156 regcomp(matchnothing, "///", REG_NOSUB); |
160 regcomp(matchnothing, "///", REG_NOSUB); |
157 dir->exclude = ucx_list_append(NULL, matchnothing); |
161 dir->exclude = ucx_list_append(NULL, matchnothing); |
158 } |
162 } |
|
163 if (trash) { |
|
164 if (trash[0] == '/') { |
|
165 dir->trash = strdup(trash); |
|
166 } else { |
|
167 char *t = util_concat_path(path, trash); |
|
168 dir->trash = util_concat_path(t, "/"); |
|
169 free(t); |
|
170 } |
|
171 |
|
172 // create trash directory |
|
173 mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; |
|
174 if (util_mkdir(dir->trash, mode)) { |
|
175 if (errno != EEXIST) { |
|
176 fprintf(stderr, "Cannot create trash directory.\n"); |
|
177 } |
|
178 } |
|
179 } |
159 |
180 |
160 ucx_map_cstr_put(directories, name, dir); |
181 ucx_map_cstr_put(directories, name, dir); |
161 |
182 |
162 return 0; |
183 return 0; |
163 } |
184 } |
170 " <directory>\n" |
191 " <directory>\n" |
171 " <!-- identifier -->\n" |
192 " <!-- identifier -->\n" |
172 " <name>documents</name>\n\n" |
193 " <name>documents</name>\n\n" |
173 " <!-- local path to the directory -->\n" |
194 " <!-- local path to the directory -->\n" |
174 " <path>/home/user/Documents</path>\n\n" |
195 " <path>/home/user/Documents</path>\n\n" |
|
196 " <!-- optional trash path -->\n" |
|
197 " <trash>.trash</trash>" |
175 " <!-- repository name specified in config.xml -->\n" |
198 " <!-- repository name specified in config.xml -->\n" |
176 " <repository>server</repository>\n\n" |
199 " <repository>server</repository>\n\n" |
177 " <!-- collection to synchronize (optional) -->\n" |
200 " <!-- collection to synchronize (optional) -->\n" |
178 " <collection>somecol</collection>\n\n" |
201 " <collection>somecol</collection>\n\n" |
179 " <!-- database file name -->\n" |
202 " <!-- database file name -->\n" |