Mail Archives: cygwin/1999/06/21/12:18:21
--- Peter Ring <PRI AT cddk DOT dk> wrote:
> What is the correct way to open, read, and write a 'text' file on a
> filesystem shared between a number of different operating systems?
> (please note that this is in effect what cygwin amounts to).
>
> The scenario could be a 'text' file shared between MacOS, WinNT, and
> some UNIX-like OS. The file might be shared in several ways, some of
> which would make it impractical (if not outright nonsense) to talk about
> one specific OS 'hosting' the file.
>
A good question to ask when wanting to create a multi-platform program that
writes to multi-platform disks. Frankly, in this situation I would open the
file in binary mode, and handle the line formatting characters within the
module. If I were writing a text file from the program I would ensure that the
last character of the line were a null so that the line formatting characters
would be eliminated by default when read.
> Some applications, e.g. emacs, try to guess from the file's content what
> to do. Obviously, this works only for interactive applications.
>
> I won't argue with the benefits of explicitly opening files 'rb'. I just
> wonder why anyone would ever want to do anytning else?
>
To deal with the native tools that exist. E.G.: Notepad (I know, a bad
example, but it's a good bad example) which opens the file in binary mode and
expects to find the \r\n to know when to display on the next line.
===
Earnie Boyd <mailto:earnie_boyd AT yahoo DOT com>
Newbies, please visit
<http://www.freeyellow.com/members5/gw32/index.html>
(If you respond to the list, then please don't include me)
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
- Raw text -