summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-03-28 08:11:52 +0000
committerGuy Harris <guy@alum.mit.edu>2000-03-28 08:11:52 +0000
commite38645134590c8a82bad7b5e2987bcff662fac6f (patch)
treec192f6626b6bd2ad5ee34a0215acb5e8b0d9a35c
parent67d2ea7af0468800983394594394d6c28b399f4e (diff)
downloadwireshark-e38645134590c8a82bad7b5e2987bcff662fac6f.tar.gz
Patches from Andreas Sikkema:
On Win32, always save a temporary capture file by copying - Win32 systems don't allow you to rename a file that is open, and we have the temporary file open. When saving by copying the raw bytes of a capture file, create the target file with "open()", using the O_BINARY flag, rather than with "creat()"; on Win32 systems, "creat()" apparently opens the file as a text file rather than a binary file. svn path=/trunk/; revision=1757
-rw-r--r--AUTHORS5
-rw-r--r--doc/ethereal.pod.template1
-rw-r--r--file.c15
3 files changed, 18 insertions, 3 deletions
diff --git a/AUTHORS b/AUTHORS
index 83c8eb86e2..9b91ca929f 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -276,6 +276,11 @@ Doug Nazar <nazard@dragoninc.on.ca> {
LDAP support
}
+Andreas Sikkema <andreas.sikkema@philips.com> {
+ Fixes to SMB dissector
+ Fixes to capture file handling on Win32
+}
+
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to
give his permission to use his version of snprintf.c.
diff --git a/doc/ethereal.pod.template b/doc/ethereal.pod.template
index d90722d46c..917809544e 100644
--- a/doc/ethereal.pod.template
+++ b/doc/ethereal.pod.template
@@ -837,6 +837,7 @@ B<http://ethereal.zing.org>.
Jochen Friedrich <jochen+ethereal@scram.de>
Paul Welchinski <paul.welchinski@telusplanet.net>
Doug Nazar <nazard@dragoninc.on.ca>
+ Andreas Sikkema <andreas.sikkema@philips.com>
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to give his
permission to use his version of snprintf.c.
diff --git a/file.c b/file.c
index 00ddc6d8df..32dbcb62cc 100644
--- a/file.c
+++ b/file.c
@@ -1,7 +1,7 @@
/* file.c
* File I/O routines
*
- * $Id: file.c,v 1.172 2000/03/26 07:03:52 sharpe Exp $
+ * $Id: file.c,v 1.173 2000/03/28 08:11:43 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -1410,6 +1410,7 @@ save_cap_file(char *fname, capture_file *cf, gboolean save_filtered,
/* The file being saved is a temporary file from a live
capture, so it doesn't need to stay around under that name;
first, try renaming the capture buffer file to the new name. */
+#ifndef WIN32
if (rename(cf->filename, fname) == 0) {
/* That succeeded - there's no need to copy the source file. */
from_filename = NULL;
@@ -1434,13 +1435,16 @@ save_cap_file(char *fname, capture_file *cf, gboolean save_filtered,
goto done;
}
}
+#else
+ do_copy = TRUE;
+ from_filename = cf->filename;
+#endif
} else {
/* It's a permanent file, so we should copy it, and not remove the
original. */
do_copy = TRUE;
from_filename = cf->filename;
}
-
/* Copy the file, if we haven't moved it. */
if (do_copy) {
/* Copy the raw bytes of the file. */
@@ -1452,7 +1456,12 @@ save_cap_file(char *fname, capture_file *cf, gboolean save_filtered,
goto done;
}
- to_fd = creat(fname, 0644);
+ /* Use open() instead of creat() so that we can pass the O_BINARY
+ flag, which is relevant on Win32; it appears that "creat()"
+ may open the file in text mode, not binary mode, but we want
+ to copy the raw bytes of the file, so we need the output file
+ to be open in binary mode. */
+ to_fd = open(fname, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
if (to_fd < 0) {
err = errno;
simple_dialog(ESD_TYPE_WARN, NULL,