aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-10-23 05:01:02 +0000
committerGuy Harris <guy@alum.mit.edu>2001-10-23 05:01:02 +0000
commitcf5a1d86e7280ec6b26a258238dd3fb3d6b31f59 (patch)
tree6b6ced95b0d95cc2f7243f2ff7546552b12f4dfa /gtk
parent04147b7dcf4e435dab2f6aa141e0e8dec7b88b06 (diff)
Add a new routine to create the ".ethereal" directory for a user.
Use that routine rather than duplicating that code in the routines to write out the preference file and filter files. Use it in the code for the color filter dialog, so that the directory in question is created if necessary. As that routine returns an error indication, have the code that calls that routine put up a message box if the attempt fails. svn path=/trunk/; revision=4065
Diffstat (limited to 'gtk')
-rw-r--r--gtk/colors.c13
-rw-r--r--gtk/filter_prefs.c17
-rw-r--r--gtk/prefs_dlg.c22
3 files changed, 41 insertions, 11 deletions
diff --git a/gtk/colors.c b/gtk/colors.c
index 4df4a807e9..ac29b6db79 100644
--- a/gtk/colors.c
+++ b/gtk/colors.c
@@ -1,7 +1,7 @@
/* colors.c
* Definitions for color structures and routines
*
- * $Id: colors.c,v 1.12 2001/10/22 22:59:26 guy Exp $
+ * $Id: colors.c,v 1.13 2001/10/23 05:01:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -39,6 +39,7 @@
#endif
#include <epan/filesystem.h>
+
#include "gtk/main.h"
#include "packet.h"
#include "colors.h"
@@ -287,9 +288,19 @@ write_filter(gpointer filter_arg, gpointer file_arg)
gboolean
write_filters(colfilter *filter)
{
+ const gchar *pf_dir_path;
const gchar *path;
FILE *f;
+ /* Create the directory that holds personal configuration files,
+ if necessary. */
+ if (create_persconffile_dir(&pf_dir_path) == -1) {
+ simple_dialog(ESD_TYPE_WARN, NULL,
+ "Can't create directory\n\"%s\"\nfor color files: %s.",
+ pf_dir_path, strerror(errno));
+ return FALSE;
+ }
+
path = get_colorfilter_file_path();
if ((f = fopen(path, "w+")) == NULL) {
simple_dialog(ESD_TYPE_CRIT, NULL,
diff --git a/gtk/filter_prefs.c b/gtk/filter_prefs.c
index 3f23d9103b..50f645035d 100644
--- a/gtk/filter_prefs.c
+++ b/gtk/filter_prefs.c
@@ -3,12 +3,11 @@
* (This used to be a notebook page under "Preferences", hence the
* "prefs" in the file name.)
*
- * $Id: filter_prefs.c,v 1.30 2001/06/27 10:00:14 guy Exp $
+ * $Id: filter_prefs.c,v 1.31 2001/10/23 05:01:02 guy Exp $
*
* Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
- *
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -33,7 +32,7 @@
#include <gtk/gtk.h>
-#include <epan.h>
+#include <epan/filesystem.h>
#include "filters.h"
#include "gtk/main.h"
@@ -709,10 +708,20 @@ static void
filter_dlg_save_cb(GtkWidget *save_bt, gpointer data)
{
filter_list_type_t list = *(filter_list_type_t *)data;
+ const char *pf_dir_path;
char *f_path;
int f_save_errno;
char *filter_type;
+ /* Create the directory that holds personal configuration files,
+ if necessary. */
+ if (create_persconffile_dir(&pf_dir_path) == -1) {
+ simple_dialog(ESD_TYPE_WARN, NULL,
+ "Can't create directory\n\"%s\"\nfor filter files: %s.",
+ pf_dir_path, strerror(errno));
+ return;
+ }
+
save_filter_list(list, &f_path, &f_save_errno);
if (f_path != NULL) {
/* We had an error saving the filter. */
diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c
index 38c91f1f82..75d2e399fa 100644
--- a/gtk/prefs_dlg.c
+++ b/gtk/prefs_dlg.c
@@ -1,7 +1,7 @@
/* prefs_dlg.c
* Routines for handling preferences
*
- * $Id: prefs_dlg.c,v 1.30 2001/10/22 22:59:26 guy Exp $
+ * $Id: prefs_dlg.c,v 1.31 2001/10/23 05:01:02 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -45,6 +45,8 @@
#include <sys/stat.h>
#endif
+#include <epan/filesystem.h>
+
#include "main.h"
#include "gtkglobals.h"
#include "packet.h"
@@ -654,12 +656,20 @@ prefs_main_save_cb(GtkWidget *save_bt, gpointer parent_w)
gui_prefs_fetch(gtk_object_get_data(GTK_OBJECT(parent_w), E_GUI_PAGE_KEY));
prefs_module_foreach(module_prefs_fetch, &must_redissect);
- /* Write the preferencs out. */
- err = write_prefs(&pf_path);
- if (err != 0) {
+ /* Create the directory that holds personal configuration files, if
+ necessary. */
+ if (create_persconffile_dir(&pf_path) == -1) {
simple_dialog(ESD_TYPE_WARN, NULL,
- "Can't open preferences file\n\"%s\": %s.", pf_path,
- strerror(err));
+ "Can't create directory\n\"%s\"\nfor preferences file: %s.", pf_path,
+ strerror(errno));
+ } else {
+ /* Write the preferencs out. */
+ err = write_prefs(&pf_path);
+ if (err != 0) {
+ simple_dialog(ESD_TYPE_WARN, NULL,
+ "Can't open preferences file\n\"%s\": %s.", pf_path,
+ strerror(err));
+ }
}
/* Now apply those preferences.