aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/file_dlg.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2005-08-19 19:40:00 +0000
committerGuy Harris <guy@alum.mit.edu>2005-08-19 19:40:00 +0000
commit38ec1644e68721d6b5afb84dce1684b943b1aee0 (patch)
tree8ffe4f642463b43885354f4dd755e59b4daf3823 /gtk/file_dlg.c
parent06823cdce8a0e63cf888c449a1b37071d622f1c3 (diff)
Add APIs to Wiretap to return the file of the size as supplied by the OS
(so if the file's gzipped, it's *NOT* the size of the file after uncompressing), and an approximation of the amount of that data read sequentially so far. Use those for various progress bars and the like. Make the fstat() in the Ascend trace reader directly use wth->fd, as it's inside Wiretap; that gets rid of the last caller of wtap_fd() (as we're no longer directly using fstat() or lseek() in Ethereal), so get rid of wtap_fd(). svn path=/trunk/; revision=15437
Diffstat (limited to 'gtk/file_dlg.c')
-rw-r--r--gtk/file_dlg.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/gtk/file_dlg.c b/gtk/file_dlg.c
index 6493738dea..ac4af2fa1c 100644
--- a/gtk/file_dlg.c
+++ b/gtk/file_dlg.c
@@ -116,10 +116,6 @@ static GtkWidget *cfmark_cb;
static GtkWidget *ft_om;
static GtkWidget *range_tb;
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
#define PREVIEW_STR_MAX 200
static double
@@ -137,9 +133,8 @@ preview_set_filename(GtkWidget *prev, const gchar *cf_name)
wtap *wth;
int err = 0;
gchar *err_info;
- struct stat cf_stat;
gchar string_buff[PREVIEW_STR_MAX];
- guint64 filesize;
+ gint64 filesize;
/* init preview labels */
@@ -181,14 +176,13 @@ preview_set_filename(GtkWidget *prev, const gchar *cf_name)
}
/* Find the size of the file. */
- if (fstat(wtap_fd(wth), &cf_stat) < 0) {
+ filesize = wtap_file_size(wth, &err);
+ if (filesize == -1) {
+ gtk_label_set_text(GTK_LABEL(label), "error getting file size");
wtap_close(wth);
return NULL;
}
-
- /* size */
- filesize = cf_stat.st_size;
- g_snprintf(string_buff, PREVIEW_STR_MAX, "%" PRIu64 " bytes", filesize);
+ g_snprintf(string_buff, PREVIEW_STR_MAX, "%" PRId64 " bytes", filesize);
label = OBJECT_GET_DATA(prev, PREVIEW_SIZE_KEY);
gtk_label_set_text(GTK_LABEL(label), string_buff);