/* * Alert box for a failed attempt to write to a file. * "err" is assumed to be a UNIX-style errno if positive and a * Wiretap error if negative. * * XXX - add explanatory secondary text for at least some of the errors; * various HIGs suggest that you should, for example, suggest that the * user remove files if the file system is full. Perhaps that's because * they're providing guidelines for people less sophisticated than the * typical Wireshark user is, but.... */ void write_failure_alert_box(const char *filename, int err) { gchar *display_basename; display_basename = g_filename_display_basename(filename); if (err < 0) { switch (err) { case WTAP_ERR_SHORT_WRITE: simple_message_box(ESD_TYPE_ERROR, NULL, NULL, "A full write couldn't be done to the file \"%s\".", display_basename); break; default: simple_message_box(ESD_TYPE_ERROR, NULL, NULL, "An error occurred while writing to the file \"%s\": %s.", display_basename, wtap_strerror(err)); break; } } else { simple_message_box(ESD_TYPE_ERROR, NULL, NULL, file_write_error_message(err), display_basename); } g_free(display_basename); }
/* * Alert box for a failed attempt to write to a file. * "err" is assumed to be a UNIX-style errno if positive and a * Wiretap error if negative. * * XXX - add explanatory secondary text for at least some of the errors; * various HIGs suggest that you should, for example, suggest that the * user remove files if the file system is full. Perhaps that's because * they're providing guidelines for people less sophisticated than the * typical Wireshark user is, but.... */ void write_failure_alert_box(const char *filename, int err) { if (err < 0) { switch (err) { case WTAP_ERR_SHORT_WRITE: simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "A full write couldn't be done to the file \"%s\".", filename); break; default: simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "An error occurred while writing to the file \"%s\": %s.", filename, wtap_strerror(err)); break; } } else { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, file_write_error_message(err), filename); } }
/* * Alert box for a failed attempt to write to a file. * "err" is assumed to be a UNIX-style errno. * * XXX - add explanatory secondary text for at least some of the errors; * various HIGs suggest that you should, for example, suggest that the * user remove files if the file system is full. Perhaps that's because * they're providing guidelines for people less sophisticated than the * typical Wireshark user is, but.... */ void write_failure_alert_box(const char *filename, int err) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, file_write_error_message(err), filename); }
static gchar* get_write_error_string(const merge_in_file_t *in_file, const int file_type, const gchar* out_filename, const int *err, gchar **err_info) { GString *err_message = g_string_new(""); gchar *display_basename = NULL; int write_err; /* in_file may be NULL */ g_assert(err != NULL); g_assert(err_info != NULL); if (*err_info == NULL) { *err_info = g_strdup("no information supplied"); } write_err = *err; display_basename = g_filename_display_basename(in_file ? in_file->filename : "UNKNOWN"); if (write_err < 0) { switch (write_err) { case WTAP_ERR_UNWRITABLE_ENCAP: /* * This is a problem with the particular frame we're writing and * the file type and subtype we're wwriting; note that, and * report the frame number and file type/subtype. */ g_string_printf(err_message, "Frame %u of \"%s\" has a network type that can't be saved in a \"%s\" file.\n", in_file ? in_file->packet_num : 0, display_basename, wtap_file_type_subtype_string(file_type)); break; case WTAP_ERR_PACKET_TOO_LARGE: /* * This is a problem with the particular frame we're writing and * the file type and subtype we're writing; note that, and report * the frame number and file type/subtype. */ g_string_printf(err_message, "Frame %u of \"%s\" is too large for a \"%s\" file.", in_file ? in_file->packet_num : 0, display_basename, wtap_file_type_subtype_string(file_type)); break; case WTAP_ERR_UNWRITABLE_REC_TYPE: /* * This is a problem with the particular record we're writing and * the file type and subtype we're writing; note that, and report * the record number and file type/subtype. */ g_string_printf(err_message, "Record %u of \"%s\" has a record type that can't be saved in a \"%s\" file.", in_file ? in_file->packet_num : 0, display_basename, wtap_file_type_subtype_string(file_type)); break; case WTAP_ERR_UNWRITABLE_REC_DATA: /* * This is a problem with the particular record we're writing and * the file type and subtype we're writing; note that, and report * the frame number and file type/subtype. */ g_string_printf(err_message, "Record %u of \"%s\" has data that can't be saved in a \"%s\" file.\n(%s)", in_file ? in_file->packet_num : 0, display_basename, wtap_file_type_subtype_string(file_type), *err_info); break; default: g_string_printf(err_message, "An error occurred while writing to the file \"%s\": %s.", out_filename, wtap_strerror(write_err)); break; } } else { /* OS error. */ g_string_printf(err_message, file_write_error_message(write_err), out_filename); } g_free(display_basename); g_free(*err_info); *err_info = g_string_free(err_message, FALSE); return *err_info; }