Always report errors in eo_save_entry().

If a particular save failed, always let the user know.

Change-Id: I618e0ff82813cd4249ab7b1714f9a50e095a1ea8
Reviewed-on: https://code.wireshark.org/review/31296
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2019-01-01 13:44:07 -08:00
parent e12270a730
commit be55c4f976
4 changed files with 8 additions and 11 deletions

View File

@ -140,7 +140,7 @@ eo_draw(void *tapdata)
g_string_free(safe_filename, TRUE);
} while (g_file_test(save_as_fullpath, G_FILE_TEST_EXISTS) && ++count < 1000);
count = 0;
if (!eo_save_entry(save_as_fullpath, entry, TRUE))
if (!eo_save_entry(save_as_fullpath, entry))
all_saved = FALSE;
g_free(save_as_fullpath);
save_as_fullpath = NULL;

View File

@ -28,7 +28,7 @@
#include "export_object_ui.h"
gboolean
eo_save_entry(const gchar *save_as_filename, export_object_entry_t *entry, gboolean show_err)
eo_save_entry(const gchar *save_as_filename, export_object_entry_t *entry)
{
int to_fd;
gint64 bytes_left;
@ -40,8 +40,7 @@ eo_save_entry(const gchar *save_as_filename, export_object_entry_t *entry, gbool
to_fd = ws_open(save_as_filename, O_WRONLY | O_CREAT | O_EXCL |
O_BINARY, 0644);
if(to_fd == -1) { /* An error occurred */
if (show_err)
report_open_failure(save_as_filename, errno, TRUE);
report_open_failure(save_as_filename, errno, TRUE);
return FALSE;
}
@ -71,8 +70,7 @@ eo_save_entry(const gchar *save_as_filename, export_object_entry_t *entry, gbool
err = errno;
else
err = WTAP_ERR_SHORT_WRITE;
if (show_err)
report_write_failure(save_as_filename, err);
report_write_failure(save_as_filename, err);
ws_close(to_fd);
return FALSE;
}
@ -80,8 +78,7 @@ eo_save_entry(const gchar *save_as_filename, export_object_entry_t *entry, gbool
ptr += bytes_written;
}
if (ws_close(to_fd) < 0) {
if (show_err)
report_write_failure(save_as_filename, errno);
report_write_failure(save_as_filename, errno);
return FALSE;
}

View File

@ -20,7 +20,7 @@ extern "C" {
/* Common between protocols */
gboolean eo_save_entry(const gchar *save_as_filename, export_object_entry_t *entry, gboolean show_err);
gboolean eo_save_entry(const gchar *save_as_filename, export_object_entry_t *entry);
#ifdef __cplusplus
}

View File

@ -146,7 +146,7 @@ bool ExportObjectModel::saveEntry(QModelIndex &index, QString filename)
return false;
if (filename.length() > 0) {
eo_save_entry(filename.toUtf8().constData(), entry, TRUE);
eo_save_entry(filename.toUtf8().constData(), entry);
}
return true;
@ -190,7 +190,7 @@ bool ExportObjectModel::saveAllEntries(QString path)
safe_filename->str, NULL);
g_string_free(safe_filename, TRUE);
} while (g_file_test(save_as_fullpath, G_FILE_TEST_EXISTS) && ++count < 1000);
if (!eo_save_entry(save_as_fullpath, entry, FALSE))
if (!eo_save_entry(save_as_fullpath, entry))
all_saved = false;
g_free(save_as_fullpath);
save_as_fullpath = NULL;