delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/01/24/22:15:15

From: fjh AT cs DOT mu DOT OZ DOT AU (Fergus Henderson)
Subject: Re: unexpected behavior of read() under win95
24 Jan 1998 22:15:15 -0800 :
Message-ID: <19980125165121.16963.cygnus.gnu-win32@mundook.cs.mu.OZ.AU>
References: <199801230406 DOT VAA17577 AT taussky DOT cs DOT colorado DOT edu>
Mime-Version: 1.0
To: Sebastian Kuzminsky <kuzminsk AT taussky DOT cs DOT colorado DOT edu>
Cc: gnu-win32 AT cygnus DOT com

On 22-Jan-1998, Sebastian Kuzminsky <kuzminsk AT taussky DOT cs DOT colorado DOT edu> wrote:
>    file_fd = open(argv[1], O_RDONLY);

If you want the return values of read() match the number of characters you
asked for, you need to open the file in binary mode, using O_BINARY:

     file_fd = open(argv[1], O_RDONLY | O_BINARY);

(The exception is that if your file system is mounted in text=binary mode,
then O_BINARY is the default.)

For text mode opens, read() is stripping out \r's.

-- 
Fergus Henderson <fjh AT cs DOT mu DOT oz DOT au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh AT 128 DOT 250 DOT 37 DOT 3         |     -- the last words of T. S. Garp.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019