2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 2013-2022 the Claws Mail team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "claws-features.h"
28 #include <glib/gi18n.h>
29 #include <gdk/gdkkeysyms.h>
37 #include "file-utils.h"
39 #include "alertpanel.h"
42 static gboolean
verify_folderlist_xml();
44 gboolean
check_file_integrity()
46 if (verify_folderlist_xml() != TRUE
)
52 static gboolean
verify_folderlist_xml()
55 static gchar
*filename
= NULL
;
56 static gchar
*bak
= NULL
;
60 gboolean fileexists
, bakexists
;
62 filename
= folder_get_list_path();
64 fileexists
= is_file_exist(filename
);
66 bak
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
,
67 FOLDER_LIST
, ".bak", NULL
);
68 bakexists
= is_file_exist(bak
);
71 date
= get_file_mtime(bak
);
72 ts
= localtime(&date
);
73 strftime(buf
, sizeof(buf
), "%a %d-%b-%Y %H:%M %Z", ts
);
76 if (!fileexists
&& bakexists
) {
81 (_("The file %s is missing! "
82 "Do you want to use the backup file from %s?"), FOLDER_LIST
,buf
);
83 aval
= alertpanel(_("Warning"), msg
, NULL
, _("_No"), NULL
, _("_Yes"),
84 NULL
, NULL
, ALERTFOCUS_FIRST
);
86 if (aval
!= G_ALERTALTERNATE
)
89 if (copy_file(bak
,filename
,FALSE
) < 0) {
90 alertpanel_warning(_("Could not copy %s to %s"),bak
,filename
);
99 node
= xml_parse_file(filename
);
100 if (!node
&& is_file_exist(bak
)) {
104 msg
= g_strdup_printf
105 (_("The file %s is empty or corrupted! "
106 "Do you want to use the backup file from %s?"), FOLDER_LIST
,buf
);
107 aval
= alertpanel(_("Warning"), msg
, NULL
, _("_No"), NULL
, _("_Yes"),
108 NULL
, NULL
, ALERTFOCUS_FIRST
);
110 if (aval
!= G_ALERTALTERNATE
)
113 if (copy_file(bak
,filename
,FALSE
) < 0) {
114 alertpanel_warning(_("Could not copy %s to %s"),bak
,filename
);