Mercurial > geeqie.yaz
comparison src/desktop_file.c @ 1637:80ba6b99478f
make sure that a directory exists on saving desktop files
author | nadvornik |
---|---|
date | Wed, 10 Jun 2009 20:45:24 +0000 |
parents | 922d7508febd |
children | fad7d30676c3 |
comparison
equal
deleted
inserted
replaced
1636:c0f6a98c9204 | 1637:80ba6b99478f |
---|---|
57 | 57 |
58 static EditorListWindow *editor_list_window = NULL; | 58 static EditorListWindow *editor_list_window = NULL; |
59 | 59 |
60 static gboolean editor_window_save(EditorWindow *ew) | 60 static gboolean editor_window_save(EditorWindow *ew) |
61 { | 61 { |
62 gchar *dir; | |
62 gchar *path; | 63 gchar *path; |
63 gchar *text; | 64 gchar *text; |
64 GtkTextIter start, end; | 65 GtkTextIter start, end; |
65 GError *error = NULL; | 66 GError *error = NULL; |
66 gboolean ret = TRUE; | 67 gboolean ret = TRUE; |
73 } | 74 } |
74 | 75 |
75 gtk_text_buffer_get_bounds(ew->buffer, &start, &end); | 76 gtk_text_buffer_get_bounds(ew->buffer, &start, &end); |
76 text = gtk_text_buffer_get_text(ew->buffer, &start, &end, FALSE); | 77 text = gtk_text_buffer_get_text(ew->buffer, &start, &end, FALSE); |
77 | 78 |
78 path = g_build_filename(get_rc_dir(), "applications", name, NULL); | 79 dir = g_build_filename(get_rc_dir(), "applications", NULL); |
79 | 80 path = g_build_filename(dir, name, NULL); |
80 if (!g_file_set_contents(path, text, -1, &error)) | 81 |
82 if (!recursive_mkdir_if_not_exists(dir, 0755)) | |
83 { | |
84 file_util_warning_dialog(_("Can't save"), _("Could not create directory"), GTK_STOCK_DIALOG_ERROR, NULL); | |
85 ret = FALSE; | |
86 } | |
87 | |
88 if (ret && !g_file_set_contents(path, text, -1, &error)) | |
81 { | 89 { |
82 file_util_warning_dialog(_("Can't save"), error->message, GTK_STOCK_DIALOG_ERROR, NULL); | 90 file_util_warning_dialog(_("Can't save"), error->message, GTK_STOCK_DIALOG_ERROR, NULL); |
83 g_error_free(error); | 91 g_error_free(error); |
84 ret = FALSE; | 92 ret = FALSE; |
85 } | 93 } |
86 | 94 |
87 g_free(path); | 95 g_free(path); |
96 g_free(dir); | |
88 g_free(text); | 97 g_free(text); |
89 layout_editors_reload_all(); | 98 layout_editors_reload_all(); |
90 return ret; | 99 return ret; |
91 } | 100 } |
92 | 101 |