Mail Archives: cygwin/1998/03/14/14:21:32
At 07:30 AM 3/12/98 -0600, Kevin Cutts wrote:
>I made a mistake and opened a binary file using fopen("file","r"). Note that
>I forgot to open it with "rb". When I read the file, I could only read part
>of the file: the read only suceeded for 2081 bytes of the 345K! Believing
>that I had made a coding mistake, I tried 'wc'. It agreed with my code: they
>both 'think' the file has 2081 bytes. However emacs and ls both realize the
>file is much larger. (When I used a truly ascii file, the size worked
>correctly. The code hack does work correctly under the Metrowerks compiler.)
Well at first guess I'd say that the behaviour is correct on NT.
Generally (since I don't know exactly what the cygnus lib does in this
situation) one of the (perhaps unfortunate) differences between text mode
and binary mode is that text mode will stop reading when it encounters
certain characters, e.g a NUL or a ^Z.
There is a definition of 'text-mode' that basically says that for the file
to be readable it must contain lines of zero or more readable ASCII
characters, where every line is terminated with a CR/LF (even the last line).
Guy
--
Guy Gascoigne - Piggford (ggp AT informix DOT com)
Software Engineer, Informix Software, Inc. (Portland, Oregon)
-
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 -