diff options
author | Guy Harris <guy@alum.mit.edu> | 2005-03-26 01:05:29 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2005-03-26 01:05:29 +0000 |
commit | 5ef0665d34a663cf0708a8105037839f72fca280 (patch) | |
tree | f346cc25cb928c03a52254adcdc201a8155c4dcd | |
parent | 67c8764353a88554f26b74487f6107bbd864989a (diff) | |
download | wireshark-5ef0665d34a663cf0708a8105037839f72fca280.tar.gz |
Create the directory for the preferences files before writing out the
"recent" file.
Have "write_recent()" handle putting up error windows for failed
attempts to write the "recent" file.
svn path=/trunk/; revision=13909
-rw-r--r-- | gtk/main.c | 9 | ||||
-rw-r--r-- | gtk/recent.c | 33 | ||||
-rw-r--r-- | gtk/recent.h | 5 |
3 files changed, 29 insertions, 18 deletions
diff --git a/gtk/main.c b/gtk/main.c index d833c87015..8afed64ac1 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -864,15 +864,12 @@ main_set_for_capture_file(gboolean have_capture_file_in) gboolean main_do_quit(void) { - gchar *rec_path; - - - /* get the current geometry, before writing it to disk */ - main_save_window_geometry(top_level); + /* get the current geometry, before writing it to disk */ + main_save_window_geometry(top_level); /* write user's recent file to disk * It is no problem to write this file, even if we do not quit */ - write_recent(&rec_path); + write_recent(); /* XXX - should we check whether the capture file is an unsaved temporary file for a live capture and, if so, diff --git a/gtk/recent.c b/gtk/recent.c index 2708ae7690..5e200f8e96 100644 --- a/gtk/recent.c +++ b/gtk/recent.c @@ -41,6 +41,7 @@ #include "ui_util.h" #include "dlg_utils.h" #include "cfilter_combo_utils.h" +#include "simple_dialog.h" #define RECENT_KEY_MAIN_TOOLBAR_SHOW "gui.toolbar_main_show" #define RECENT_KEY_FILTER_TOOLBAR_SHOW "gui.filter_toolbar_show" @@ -91,12 +92,13 @@ find_index_from_string_array(char *needle, char **haystack, int default_value) return default_value; } -/* Write out "recent" to the user's recent file, and return 0. - If we got an error, stuff a pointer to the path of the recent file - into "*pf_path_return", and return the errno. */ -int -write_recent(char **rf_path_return) +/* Attempt to Write out "recent" to the user's recent file. + If we got an error report it with a dialog box and return FALSE, + otherwise return TRUE. */ +gboolean +write_recent(void) { + char *pf_dir_path; char *rf_path; FILE *rf; @@ -106,10 +108,23 @@ write_recent(char **rf_path_return) * so that duplication can be avoided with filter.c */ + /* Create the directory that holds personal configuration files, if + necessary. */ + if (create_persconffile_dir(&pf_dir_path) == -1) { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Can't create directory\n\"%s\"\nfor recent file: %s.", pf_dir_path, + strerror(errno)); + g_free(pf_dir_path); + return FALSE; + } + rf_path = get_persconffile_path(RECENT_FILE_NAME, TRUE); if ((rf = fopen(rf_path, "w")) == NULL) { - *rf_path_return = rf_path; - return errno; + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "Can't open recent file\n\"%s\": %s.", rf_path, + strerror(errno)); + g_free(rf_path); + return FALSE; } fputs("# Recent settings file for Ethereal " VERSION ".\n" @@ -213,10 +228,10 @@ write_recent(char **rf_path_return) fclose(rf); /* XXX - catch I/O errors (e.g. "ran out of disk space") and return - an error indication, or maybe write to a new preferences file and + an error indication, or maybe write to a new recent file and rename that file on top of the old one only if there are not I/O errors. */ - return 0; + return TRUE; } diff --git a/gtk/recent.h b/gtk/recent.h index 6307b58b1d..f034962c35 100644 --- a/gtk/recent.h +++ b/gtk/recent.h @@ -67,10 +67,9 @@ extern recent_settings_t recent; /** Write recent settings file. * - * @param rf_path_return path to recent file if function failed - * @return 0 if succeeded, errno if failed + * @return TRUE if succeeded, FALSE if failed */ -extern int write_recent(char **rf_path_return); +extern gboolean write_recent(void); /** Read recent settings file. * |