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
This commit is contained in:
Guy Harris 2000-03-28 08:11:52 +00:00
parent 67d2ea7af0
commit e386451345
3 changed files with 18 additions and 3 deletions

View File

@ -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.

View File

@ -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.

15
file.c
View File

@ -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,