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: binary/text files


--- Aldo Mazzilli <aldo.mazzilli@inria.fr> wrote:
> Hello there,
> 
> can someone tell me how CYGWIN32 handles text and binary files ??
> 
> Especially with :
> 
> - open() call 
> - pipes and sockets
> - tty's and ptys
> - cat() command
> 
> What is the best way to control the case where \r characters are
> inserted in front of each \n.
> 
> The problem is because I have a program which counts the bytes of a
> file, and I have to modifiy it in order to :
> -  count 1 byte at each newline under Unix
> - count 2 bytes at each newline under Win32
> 
> What is the best way to do that ??

First let me say read the documentation and search the archives.  There exists
lots of information on this subject.

Now, to answer the counting problem.  Open the files in O_BINARY or "rb" mode. 
The \r will then be returned as data and the number of characters returned by
the read will be correct.
===
YAWIA,
Earnie Boyd <mailto:earnie_boyd@yahoo.com>

Newbies, please visit
<http://www.freeyellow.com/members5/gw32/index.html>
_________________________________________________________
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]