delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/09/13/04:17:32

From: michael AT weiser DOT saale-net DOT de (Michael Weiser)
Subject: Re: I/O redirection of binary data
13 Sep 1998 04:17:32 -0700 :
Message-ID: <3603a207.10090369.cygnus.gnu-win32@mail.weiser.saale-net.de>
References: <199809110932 DOT LAA13319 AT geologi DOT uio DOT no>
Mime-Version: 1.0
To: Paul Wessel <pal DOT wessel AT geologi DOT uio DOT no>
Cc: gnu-win32 AT cygnus DOT com

Hello Paul, you wrote:
>POSIX recommends that one could use the b(inary) modifier
>in fopen for portability since the b has no effect on POSIX
>systems but may be needed in, say, MS-DOS.  How can
>I deal with this in redirection?  I often have a program do
>
>program > data
>
>and data is supposed to be binary but under gnu-win32 I noticed
>that the file size is incorrect (it is larger probably due to CR/LFs?)
>compared to POSIX systems.  This also causes problems when
>trying to read the file with anotherprogram < data.
This happens because by default mount points in cygwin32 are
nonbinary. This means that any LF written to disk gets converted to
CRLF if the application didn't specify the b flag when opening the
file. As bash doesn't do so and redirection is handled by bash, your
problem arises.

>Are there any non-intrusive solutions?  WHen using stdout I am
>not using fopen so I cannot easily use the binary flag...
The binary flag in this context is the type of your mount point.
Simply remount it in binary mode or set fbinary for each mount point
in HKEY_CURRENT_USER\Software\Cygnus Solutions\CYGWIN.DLL
Setup\b15.0\mounts\ to 1.
-- 
bye, Michael
-
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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019