- /*
- * this is very ugly for now
- */
- /*if( options_get_int("datafile", "autosave") )*/
-
- if( load_database(datafile) == 2 ) {
- char *tmp = strconcat(getenv("HOME"),
- "/" DATAFILE, NULL);
-
- if( safe_strcmp(tmp, datafile) ) {
- refresh_screen();
- statusline_msg("Sorry, the specified file does "
- "not appear to be a valid abook addressbook");
- statusline_msg("Will open default addressbook...");
- free(datafile);
- datafile = tmp;
- load_database(datafile);
- } else
- free(tmp);
- }
+ if(!datafile_writeable()) {
+ char *s = mkstr("File %s is not writeable", datafile);
+ refresh_screen();
+ statusline_msg(s);
+ free(s);
+ if(load_database(datafile) || !statusline_ask_boolean(
+ "If you continue all changes will "
+ "be lost. Do you want to continue?", FALSE)) {
+ close_config();
+ close_database();
+ close_ui();
+ exit(1);
+ }
+ } else
+ load_database(datafile);