File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -124,6 +124,8 @@ suscan_config_context_new(const char *name)
124124 SU_TRYCATCH (new -> save_file = strbuild ("%s.xml" , name ), goto fail );
125125 SU_TRYCATCH (new -> list = suscan_object_new (SUSCAN_OBJECT_TYPE_SET ), goto fail );
126126
127+ new -> save = SU_TRUE ;
128+
127129 return new ;
128130
129131fail :
@@ -304,9 +306,17 @@ suscan_config_context_scan(suscan_config_context_t *context)
304306 return ok ;
305307}
306308
309+ void
310+ suscan_config_context_set_save (
311+ suscan_config_context_t * ctx ,
312+ SUBOOL save )
313+ {
314+ ctx -> save = save ;
315+ }
316+
307317/*
308318 * TODO: This code is not robust. Save to a temporary file and
309- * then move it to the right destionation .
319+ * then move it to the right destination .
310320 */
311321
312322SUPRIVATE SUBOOL
@@ -318,9 +328,11 @@ suscan_config_context_save(suscan_config_context_t *context)
318328 suscan_object_t * set = NULL ;
319329 size_t size ;
320330 void * data = NULL ;
321-
322331 SUBOOL ok = SU_FALSE ;
323332
333+ if (!context -> save )
334+ return SU_TRUE ;
335+
324336 if (context -> on_save != NULL )
325337 SU_TRYCATCH ((context -> on_save )(context , context -> userdata ), goto done );
326338
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ const char *suscan_confdb_get_local_path(void);
3737struct suscan_config_context {
3838 char * name ;
3939 char * save_file ;
40+ SUBOOL save ;
4041
4142 PTR_LIST (char , path );
4243
@@ -51,6 +52,10 @@ typedef struct suscan_config_context suscan_config_context_t;
5152suscan_config_context_t * suscan_config_context_lookup (const char * name );
5253suscan_config_context_t * suscan_config_context_assert (const char * name );
5354
55+ void suscan_config_context_set_save (
56+ suscan_config_context_t * ctx ,
57+ SUBOOL save );
58+
5459SUBOOL suscan_config_context_add_path (
5560 suscan_config_context_t * ctx ,
5661 const char * path );
You can’t perform that action at this time.
0 commit comments