summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2011-05-09 05:30:59 +0000
committerGuy Harris <guy@alum.mit.edu>2011-05-09 05:30:59 +0000
commit88a1ed85e3156e80c3fed4848d651aae433dc8d8 (patch)
treeab444a6fa6b32f20c68c7689470957750b11e699 /file.c
parent42ba70cf9c7b906c73721065e5b7425bf2ff663e (diff)
downloadwireshark-88a1ed85e3156e80c3fed4848d651aae433dc8d8.tar.gz
From Jakub Zawadzki: for file read progress bars, use the raw offset in
the file, rather than the offset in the uncompressed data stream. That way we don't get the "hey, we're more than 100% into the file, better refigure this" surprise. svn path=/trunk/; revision=37025
Diffstat (limited to 'file.c')
-rw-r--r--file.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/file.c b/file.c
index 9e369e698f..b88c056e5a 100644
--- a/file.c
+++ b/file.c
@@ -458,17 +458,6 @@ calc_progbar_val(capture_file *cf, gint64 size, gint64 file_pos, gchar *status_s
*/
size = wtap_file_size(cf->wth, NULL);
- /* Another possibility is that we're reading a compressed file and we've
- * read more (uncompressed) data from the file than exists in the
- * (compressed) file. So check how much data we've actually read.
- *
- * This is inside this "if val > 1.0" check to avoid the lseek() when
- * reading uncompressed files. Testing has (thus far) shown no progress
- * bar weirdness resulting from switching from the data offset (when
- * reading the first part of the file) to the real file position.
- */
- file_pos = wtap_read_so_far(cf->wth, NULL);
-
if (size >= 0)
progbar_val = (gfloat) file_pos / (gfloat) size;
@@ -497,6 +486,7 @@ cf_read(capture_file *cf, gboolean from_save)
const char *errmsg;
char errmsg_errno[1024+1];
gint64 data_offset;
+ gint64 file_pos;
progdlg_t *volatile progbar = NULL;
gboolean stop_flag;
volatile gint64 size;
@@ -561,11 +551,13 @@ cf_read(capture_file *cf, gboolean from_save)
while ((wtap_read(cf->wth, &err, &err_info, &data_offset))) {
if (size >= 0) {
count++;
+ file_pos = wtap_read_so_far(cf->wth);
+
/* Create the progress bar if necessary.
* Check whether it should be created or not every MIN_NUMBER_OF_PACKET
*/
if ((progbar == NULL) && !(count % MIN_NUMBER_OF_PACKET)){
- progbar_val = calc_progbar_val(cf, size, data_offset, status_str, sizeof(status_str));
+ progbar_val = calc_progbar_val(cf, size, file_pos, status_str, sizeof(status_str));
if (from_save == FALSE)
progbar = delayed_create_progress_dlg("Loading", name_ptr,
TRUE, &stop_flag, &start_time, progbar_val);
@@ -579,9 +571,9 @@ cf_read(capture_file *cf, gboolean from_save)
to repaint what's pending, and doing so may involve an "ioctl()"
to see if there's any pending input from an X server, and doing
that for every packet can be costly, especially on a big file. */
- if (data_offset >= progbar_nextstep) {
+ if (file_pos >= progbar_nextstep) {
if (progbar != NULL) {
- progbar_val = calc_progbar_val(cf, size, data_offset, status_str, sizeof(status_str));
+ progbar_val = calc_progbar_val(cf, size, file_pos, status_str, sizeof(status_str));
/* update the packet bar content on the first run or frequently on very large files */
#ifdef HAVE_LIBPCAP
if (progbar_quantum > 500000 || displayed_once == 0) {
@@ -1322,7 +1314,7 @@ cf_merge_files(char **out_filenamep, int in_file_count,
/* Get the sum of the seek positions in all of the files. */
file_pos = 0;
for (i = 0; i < in_file_count; i++)
- file_pos += wtap_read_so_far(in_files[i].wth, NULL);
+ file_pos += wtap_read_so_far(in_files[i].wth);
progbar_val = (gfloat) file_pos / (gfloat) f_len;
if (progbar_val > 1.0f) {
/* Some file probably grew while we were reading it.