Subject: Re: unexpected behavior of read() under win95
From: [email-masked] (Fergus Henderson)

24 Jan 1998 22:15:15 -0800
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
To: Sebastian Kuzminsky <[email-masked]>
Cc: [email-masked]

On 22-Jan-1998, Sebastian Kuzminsky <[email-masked]> 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 <[email-masked]>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger [email-masked]         |     -- the last words of T. S. Garp.
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".