diff options
author | Guy Harris <guy@alum.mit.edu> | 2017-04-18 14:02:18 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2017-04-18 21:02:54 +0000 |
commit | 1015fa04313893ba81bca678534fad7a4630d6c8 (patch) | |
tree | ae8efa94137f1d17818f19971c4a304abdc34f2a /file.c | |
parent | 870b3d2c0f46addafb6a7dab4278de48edc33535 (diff) |
Have a common "capture file close alert box" routine.
Take cf_close_failure_alert_box() and put it into libui, with the name
cfile_close_failure_alert_box(). Use it not only in file.c but also
in ui/export_pdu_ui_utils.c, ui/gtk/file_import_dlg.c, and
ui/qt/import_text_dialog.cpp where the error we get back isn't
necessarily an errno.
Have ui/gtk/file_import_dlg.c and ui/qt/import_text_dialog.cpp also use
cfile_open_failure_alert_box() on open errors.
Change-Id: I987f339a23ea58609390306a319923e7f92d5c07
Reviewed-on: https://code.wireshark.org/review/21203
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 45 |
1 files changed, 2 insertions, 43 deletions
@@ -133,7 +133,6 @@ static gboolean find_packet(capture_file *cf, static const char *cf_get_user_packet_comment(capture_file *cf, const frame_data *fd); static void cf_rename_failure_alert_box(const char *filename, int err); -static void cf_close_failure_alert_box(const char *filename, int err); static void ref_time_packets(capture_file *cf); /* Seconds spent processing packets between pushing UI updates. */ @@ -4658,7 +4657,7 @@ cf_save_records(capture_file *cf, const char *fname, guint save_format, } if (!wtap_dump_close(pdh, &err)) { - cf_close_failure_alert_box(fname, err); + cfile_close_failure_alert_box(fname, err); goto fail; } @@ -4897,7 +4896,7 @@ cf_export_specified_packets(capture_file *cf, const char *fname, } if (!wtap_dump_close(pdh, &err)) { - cf_close_failure_alert_box(fname, err); + cfile_close_failure_alert_box(fname, err); goto fail; } @@ -4968,46 +4967,6 @@ cf_rename_failure_alert_box(const char *filename, int err) g_free(display_basename); } -/* Check for write errors - if the file is being written to an NFS server, - a write error may not show up until the file is closed, as NFS clients - might not send writes to the server until the "write()" call finishes, - so that the write may fail on the server but the "write()" may succeed. */ -static void -cf_close_failure_alert_box(const char *filename, int err) -{ - gchar *display_basename; - - if (err < 0) { - /* Wiretap error. */ - display_basename = g_filename_display_basename(filename); - switch (err) { - - case WTAP_ERR_CANT_CLOSE: - simple_error_message_box( - "The file \"%s\" couldn't be closed for some unknown reason.", - display_basename); - break; - - case WTAP_ERR_SHORT_WRITE: - simple_error_message_box( - "Not all the packets could be written to the file \"%s\".", - display_basename); - break; - - default: - simple_error_message_box( - "An error occurred while closing the file \"%s\": %s.", - display_basename, wtap_strerror(err)); - break; - } - g_free(display_basename); - } else { - /* OS error. - We assume that a close error from the OS is really a write error. */ - write_failure_alert_box(filename, err); - } -} - /* Reload the current capture file. */ void cf_reload(capture_file *cf) { |