Stephen Turner wrote:
> On Thu, 8 Apr 1999, Jeremy Wadsack wrote:
> >
> > Properly, if you open a file as binary and
> > process if until eof, then the system should not let you process beyond the end
> > of it.
>
> Well, that's what I assumed. But in which case, I can't understand what
> the point of CTRL-Z is. Why do text files terminate at CTRL-Z, if there's
> some other later termination point, which isn't a CTRL-Z? Why have two
> termination markers? Is it some sort of DOS hangover?
I think (someone correct me if I'm wrong) that this is a CP/M hangover (right word
choice there too :) !
I never understood why there was a difference: The file systems (FAT, FAT32, NTFS)
that have these also keep track the length of a file so if you use a DOS call and,
say, ask for report.txt, in text mode it opens the file and reads until the Ctrl-Z.
If you do the same and open in bin mode it keeps reading to the end of the file as
determined by the file system interface. (Which, yes, is a redundant specifier in a
text mode file.) So I guess my recommendation (and what I do, generally) is open
everything as binary. Doesn't seem to hurt and that way you never have to worry.
In fact, here's an excerpt from MSVC6.0 CRT, which implies that the above
recommendation is fairly common practice (not that Microsoft is a company to get
examples of "good" programming from; after all they're the ones perpetuating this
text/binary mode thing):
/***
*binmode.c - set global file mode to binary
*
* Copyright (c) 1989-1997, Microsoft Corporation. All rights reserved.
*
*Purpose:
* Sets the global file mode flag to binary. Linking with this file
* sets all files to be opened in binary mode.
*
*******************************************************************************/
#include <cruntime.h>
#include <fcntl.h>
#include <stdlib.h>
/* set default file mode */
int _fmode = _O_BINARY;
--
Jeremy Wadsack
OutQuest Magazine
a Wadsack-Allen publication
--------------------------------------------------------------------
This is the analog-help mailing list. To unsubscribe from this
mailing list, send mail to [EMAIL PROTECTED]
with "unsubscribe analog-help" in the main BODY OF THE MESSAGE.
--------------------------------------------------------------------