from Jaap Keuter:
authorUlf Lamping <ulf.lamping@web.de>
Tue, 8 Nov 2005 22:24:53 +0000 (22:24 -0000)
committerUlf Lamping <ulf.lamping@web.de>
Tue, 8 Nov 2005 22:24:53 +0000 (22:24 -0000)
Anyone having objections to idea of stopping the load of a capture file
i.s.o. cancelling it? I'm refering to WishList Data I/O item #6.
It seems a very reasonable idea and easy to implement.

I've done some extensions:
-Improve the corresponding comment on the implications why this is useful
-added a new simple_dialog text to explain what's really going on (simply using the WTAP truncated packet message was a bit misleading)

svn path=/trunk/; revision=16441

file.c

diff --git a/file.c b/file.c
index b2cd59832538fa064cb85a10e73590653caffbf0..57729564eb572eb5f5bceacd20113c27a1efa36a 100644 (file)
--- a/file.c
+++ b/file.c
@@ -446,14 +446,12 @@ cf_read(capture_file *cf)
     }
 
     if (stop_flag) {
-      /* Well, the user decided to abort the read.  Destroy the progress
-         bar, close the capture file, and return CF_READ_ABORTED so our caller
-        can do whatever is appropriate when that happens. */
-      destroy_progress_dlg(progbar);
-      cf->state = FILE_READ_ABORTED;   /* so that we're allowed to close it */
-      packet_list_thaw();              /* undo our freeze */
-      cf_close(cf);
-      return CF_READ_ABORTED;
+      /* Well, the user decided to abort the read. He/She will be warned and 
+           it might be enough for him/her to work with the already loaded packets. 
+               This is especially true for very large capture files, where you don't 
+               want to wait loading the whole file (which may last minutes or even 
+               hours even on fast machines) just to see that it was the wrong file. */
+      break;
     }
     read_packet(cf, data_offset);
   }
@@ -488,6 +486,18 @@ cf_read(capture_file *cf)
   if (cf->first_displayed != NULL)
     packet_list_select_row(0);
 
+  if(stop_flag) {
+    simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, 
+          "%sFile loading was cancelled!%s\n"
+          "\n"
+                 "The remaining packets in the file were discarded.\n"
+          "\n"
+          "As a lot of packets from the original file will be missing,\n"
+                 "remember to be careful when saving the current content to a file.\n",
+          simple_dialog_primary_start(), simple_dialog_primary_end());
+    return CF_READ_ERROR;
+  }
+
   if (err != 0) {
     /* Put up a message box noting that the read failed somewhere along
        the line.  Don't throw out the stuff we managed to read, though,