gboolean cache_sim_data_save(CacheData *cd) { SecureSaveInfo *ssi; gchar *pathl; if (!cd || !cd->path) return FALSE; pathl = path_from_utf8(cd->path); ssi = secure_open(pathl); g_free(pathl); if (!ssi) { log_printf("Unable to save sim cache data: %s\n", cd->path); return FALSE; } secure_fprintf(ssi, "SIMcache\n#%s %s\n", PACKAGE, VERSION); cache_sim_write_dimensions(ssi, cd); cache_sim_write_date(ssi, cd); cache_sim_write_checksum(ssi, cd); cache_sim_write_md5sum(ssi, cd); cache_sim_write_similarity(ssi, cd); if (secure_close(ssi)) { log_printf(_("error saving sim cache data: %s\nerror: %s\n"), cd->path, secsave_strerror(secsave_errno)); return FALSE; } return TRUE; }
static gboolean collection_save_private(CollectionData *cd, const gchar *path) { SecureSaveInfo *ssi; GList *work; gchar *pathl; if (!path && !cd->path) return FALSE; if (!path) { path = cd->path; } pathl = path_from_utf8(path); ssi = secure_open(pathl); g_free(pathl); if (!ssi) { log_printf(_("failed to open collection (write) \"%s\"\n"), path); return FALSE; } secure_fprintf(ssi, "%s collection\n", GQ_COLLECTION_MARKER); secure_fprintf(ssi, "#created with %s version %s\n", GQ_APPNAME, VERSION); collection_update_geometry(cd); if (cd->window_read) { secure_fprintf(ssi, "#geometry: %d %d %d %d\n", cd->window_x, cd->window_y, cd->window_w, cd->window_h); } work = cd->list; while (work && secsave_errno == SS_ERR_NONE) { CollectInfo *ci = work->data; secure_fprintf(ssi, "\"%s\"\n", ci->fd->path); work = work->next; } secure_fprintf(ssi, "#end\n"); if (secure_close(ssi)) { log_printf(_("error saving collection file: %s\nerror: %s\n"), path, secsave_strerror(secsave_errno)); return FALSE; } if (!cd->path || strcmp(path, cd->path) != 0) { gchar *buf = cd->path; cd->path = g_strdup(path); path = cd->path; g_free(buf); g_free(cd->name); cd->name = g_strdup(filename_from_path(cd->path)); collection_path_changed(cd); } cd->changed = FALSE; return TRUE; }
gboolean save_config_to_file(const gchar *utf8_path, ConfOptions *options) { SecureSaveInfo *ssi; gchar *rc_pathl; GString *outstr; gint indent = 0; GList *work; rc_pathl = path_from_utf8(utf8_path); ssi = secure_open(rc_pathl); g_free(rc_pathl); if (!ssi) { log_printf(_("error saving config file: %s\n"), utf8_path); return FALSE; } outstr = g_string_new(""); g_string_append_printf(outstr, "<!--\n"); g_string_append_printf(outstr, "######################################################################\n"); g_string_append_printf(outstr, "# %30s config file version %-10s #\n", GQ_APPNAME, VERSION); g_string_append_printf(outstr, "######################################################################\n"); WRITE_SEPARATOR(); WRITE_STRING("# Note: This file is autogenerated. Options can be changed here,\n"); WRITE_STRING("# but user comments and formatting will be lost.\n"); WRITE_SEPARATOR(); WRITE_STRING("-->\n"); WRITE_SEPARATOR(); WRITE_STRING("<gq>\n"); indent++; WRITE_NL(); WRITE_STRING("<global\n"); indent++; write_global_attributes(outstr, indent + 1); indent--; WRITE_STRING(">\n"); indent++; write_color_profile(outstr, indent); WRITE_SEPARATOR(); filter_write_list(outstr, indent); WRITE_SEPARATOR(); keyword_tree_write_config(outstr, indent); indent--; WRITE_NL(); WRITE_STRING("</global>\n"); WRITE_SEPARATOR(); /* Layout Options */ work = layout_window_list; while (work) { LayoutWindow *lw = work->data; layout_write_config(lw, outstr, indent); work = work->next; } indent--; WRITE_NL(); WRITE_STRING("</gq>\n"); WRITE_SEPARATOR(); secure_fputs(ssi, outstr->str); g_string_free(outstr, TRUE); if (secure_close(ssi)) { log_printf(_("error saving config file: %s\nerror: %s\n"), utf8_path, secsave_strerror(secsave_errno)); return FALSE; } return TRUE; }