]> git.samba.org - metze/wireshark/wip.git/commitdiff
From Evan Huus:
authorAnders Broman <anders.broman@ericsson.com>
Sun, 24 Jun 2012 15:08:41 +0000 (15:08 -0000)
committerAnders Broman <anders.broman@ericsson.com>
Sun, 24 Jun 2012 15:08:41 +0000 (15:08 -0000)
Size wrong in "File Set List" for just-finished captures.

https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=7370

svn path=/trunk/; revision=43455

file.c
fileset.c
fileset.h

diff --git a/file.c b/file.c
index 7fdbf1747ac4b2af76d9de4d6b0c19a05e9e0c1b..e5c75f556e025f10f33dc912b0d087e1b29099d2 100644 (file)
--- a/file.c
+++ b/file.c
@@ -953,6 +953,10 @@ cf_finish_tail(capture_file *cf, int *err)
      packets we've read. */
   cf->lnk_t = wtap_file_encap(cf->wth);
 
+  /* Update the details in the file-set dialog, as the capture file
+   * has likely grown since we first stat-ed it */
+  fileset_update_file(cf->filename);
+
   if (*err != 0) {
     /* We got an error reading the capture file.
        XXX - pop up a dialog box? */
index 43243a97c7169bd2c39d79539fae40d1befe96f4..f4c485b2b0ffbed908682219651e57d30434ae7c 100644 (file)
--- a/fileset.c
+++ b/fileset.c
@@ -171,6 +171,50 @@ fileset_is_file_in_set(const char *fname1, const char *fname2)
     return TRUE;
 }
 
+/* GCompareFunc helper for g_list_find_custom() */
+static gint
+fileset_find_by_path(gconstpointer a, gconstpointer b)
+{
+    const fileset_entry *entry;
+    const char *path;
+
+    entry = (const fileset_entry *) a;
+    path  = (const char *) b;
+
+    return g_strcmp0(entry->fullname, path);
+}
+
+/* update the time and size of this file in the list */
+void
+fileset_update_file(const char *path)
+{
+    int fh, result;
+    ws_statb64 buf;
+    fileset_entry *entry = NULL;
+    GList *entry_list;
+
+    fh = ws_open( path, O_RDONLY, 0000 /* no creation so don't matter */);
+    if(fh !=  -1) {
+
+        /* Get statistics */
+        result = ws_fstat64( fh, &buf );
+
+        /* Show statistics if they are valid */
+        if( result == 0 ) {
+            entry_list = g_list_find_custom(set.entries, path,
+                                            fileset_find_by_path);
+
+            if (entry_list) {
+                entry = (fileset_entry *) entry_list->data;
+                entry->ctime    = buf.st_ctime;
+                entry->mtime    = buf.st_mtime;
+                entry->size     = buf.st_size;
+            }
+        }
+
+        ws_close(fh);
+    }
+}
 
 /* we know this file is part of the set, so add it */
 static fileset_entry *
index c6d0dd9294289092da793bafa7bce67c3a90a722..95d3174e71e82903d945879c33c566ad46b3cddd 100644 (file)
--- a/fileset.h
+++ b/fileset.h
@@ -67,6 +67,8 @@ extern void fileset_file_closed(void);
 
 extern void fileset_update_dlg(void);
 
+extern void fileset_update_file(const char *path);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */