aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/file_dlg.c23
-rw-r--r--gtk/main.c68
2 files changed, 44 insertions, 47 deletions
diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c
index 131ade221b..2d2fe30816 100644
--- a/gtk/file_dlg.c
+++ b/gtk/file_dlg.c
@@ -998,8 +998,8 @@ file_merge_ok_cb(GtkWidget *w, gpointer fs) {
int err;
gboolean merge_ok;
char *in_filenames[2];
- int out_fd;
- char tmpname[128+1];
+ int out_fd;
+ char tmpname[128+1];
#if (GTK_MAJOR_VERSION == 2 && GTK_MINOR_VERSION >= 4) || GTK_MAJOR_VERSION > 2
cf_name = g_strdup(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs)));
@@ -1030,33 +1030,32 @@ file_merge_ok_cb(GtkWidget *w, gpointer fs) {
/* merge or append the two files */
rb = OBJECT_GET_DATA(w, E_MERGE_CHRONO_KEY);
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (rb))) {
- /* chonological order */
+ /* chronological order */
in_filenames[0] = cfile.filename;
in_filenames[1] = cf_name;
- merge_ok = merge_n_files(out_fd, 2, in_filenames, filetype, FALSE, &err);
+ merge_ok = cf_merge_files(tmpname, out_fd, 2, in_filenames,
+ filetype, FALSE);
} else {
rb = OBJECT_GET_DATA(w, E_MERGE_PREPEND_KEY);
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (rb))) {
/* prepend file */
in_filenames[0] = cfile.filename;
in_filenames[1] = cf_name;
- merge_ok = merge_n_files(out_fd, 2, in_filenames, filetype, TRUE, &err);
+ merge_ok = cf_merge_files(tmpname, out_fd, 2, in_filenames,
+ filetype, TRUE);
} else {
/* append file */
in_filenames[0] = cf_name;
in_filenames[1] = cfile.filename;
- merge_ok = merge_n_files(out_fd, 2, in_filenames, filetype, TRUE, &err);
+ merge_ok = cf_merge_files(tmpname, out_fd, 2, in_filenames,
+ filetype, TRUE);
}
}
g_free(cf_name);
- if(!merge_ok) {
- /* merge failed */
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "An error occurred while merging the files: %s.",
- wtap_strerror(err));
- close(out_fd);
+ if (!merge_ok) {
+ close(out_fd); /* XXX - it's already closed, right? */
if (rfcode != NULL)
dfilter_free(rfcode);
return;
diff --git a/gtk/main.c b/gtk/main.c
index 25e5dc30ab..259e1c2cd4 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1319,53 +1319,51 @@ dnd_merge_files(int in_file_count, char **in_filenames)
out_fd = create_tempfile(tmpname, sizeof tmpname, "ether");
/* merge the files in chonological order */
- merge_ok = merge_n_files(out_fd, in_file_count, in_filenames, WTAP_FILE_PCAP, FALSE, &err);
-
- if(!merge_ok) {
- /* merge failed */
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "An error occurred while merging the files: \"%s\".",
- wtap_strerror(err));
- close(out_fd);
- return;
- }
+ merge_ok = cf_merge_files(tmpname, out_fd, in_file_count, in_filenames,
+ WTAP_FILE_PCAP, FALSE);
- cf_close(&cfile);
+ if (!merge_ok) {
+ /* merge failed */
+ close(out_fd); /* XXX - isn't it already closed? */
+ return;
+ }
- /* Try to open the merged capture file. */
- if ((err = cf_open(tmpname, TRUE /* temporary file */, &cfile)) != 0) {
- /* We couldn't open it; don't dismiss the open dialog box,
- just leave it around so that the user can, after they
- dismiss the alert box popped up for the open error,
- try again. */
- return;
- }
+ cf_close(&cfile);
- switch (cf_read(&cfile)) {
+ /* Try to open the merged capture file. */
+ if ((err = cf_open(tmpname, TRUE /* temporary file */, &cfile)) != 0) {
+ /* We couldn't open it; don't dismiss the open dialog box,
+ just leave it around so that the user can, after they
+ dismiss the alert box popped up for the open error,
+ try again. */
+ return;
+ }
- case READ_SUCCESS:
- case READ_ERROR:
- /* Just because we got an error, that doesn't mean we were unable
- to read any of the file; we handle what we could get from the
- file. */
- break;
+ switch (cf_read(&cfile)) {
- case READ_ABORTED:
- /* The user bailed out of re-reading the capture file; the
- capture file has been closed - just free the capture file name
- string and return (without changing the last containing
- directory). */
- return;
- }
+ case READ_SUCCESS:
+ case READ_ERROR:
+ /* Just because we got an error, that doesn't mean we were unable
+ to read any of the file; we handle what we could get from the
+ file. */
+ break;
+
+ case READ_ABORTED:
+ /* The user bailed out of re-reading the capture file; the
+ capture file has been closed - just free the capture file name
+ string and return (without changing the last containing
+ directory). */
+ return;
+ }
- gtk_widget_grab_focus(packet_list);
+ gtk_widget_grab_focus(packet_list);
}
/* open/merge the dnd file */
void
dnd_open_file_cmd(GtkSelectionData *selection_data)
{
- int err;
+ int err;
gchar *cf_name, *cf_name_freeme;
int in_files;
gpointer dialog;