Ethereal-dev: Re: [ethereal-dev] [PATCH] Saving a file in WIN32 complete

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Gilbert Ramirez <gram@xxxxxxxxxx>
Date: Thu, 23 Mar 2000 10:42:23 -0600
On Thu, Mar 23, 2000 at 09:00:58AM -0600, andreas.sikkema@xxxxxxxxxxx wrote:
> 
> 
> 
> This worked for me
> -- 
> Andreas Sikkema
> andreas.sikkema@xxxxxxxxxxx
> "Standing barefoot in a river of clues, most people would
>          not get their toes wet." - Brian Kantor in a.s.r.
>  - file.c.patch

This version of the patch, however, gets rid of the need for an #ifdef
since open() will work on Unix, too. For non-Win32 platforms, we set
O_BINARY to 0, so OR-ing it causes no harm.

--gilbert
Index: file.c
===================================================================
RCS file: /usr/local/cvsroot/ethereal/file.c,v
retrieving revision 1.171
diff -u -r1.171 file.c
--- file.c	2000/03/20 04:55:10	1.171
+++ file.c	2000/03/23 16:37:58
@@ -1451,7 +1451,9 @@
 	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 */
+      to_fd = open(fname, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0644);
       if (to_fd < 0) {
       	err = errno;
 	simple_dialog(ESD_TYPE_WARN, NULL,