This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: unexpected behavior of read() under win95


On 22-Jan-1998, Sebastian Kuzminsky <kuzminsk@taussky.cs.colorado.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@cs.mu.oz.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@128.250.37.3         |     -- the last words of T. S. Garp.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]