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: LF vs. CR/LF (WAS: Problems with libtiff!)


--- Peter Ring <PRI@cddk.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@yahoo.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@sourceware.cygnus.com


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