delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/07/03/15:33:39

From: swift AT world DOT std DOT com (Peter Lu)
Subject: question/problem using fcntl to change file mode from text to binary
3 Jul 1997 15:33:39 -0700 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <33BC1462.7119.cygnus.gnu-win32@world.std.com>
Mime-Version: 1.0
X-Mailer: Mozilla 3.0 (X11; I; HP-UX A.09.07 9000/777)
Original-To: gnu-win32 AT cygnus DOT com
Original-Sender: owner-gnu-win32 AT cygnus DOT com

Hi,

	I am having problems using fcntl() to change a file which was
opened in text mode that I'd like to use in binary mode.  In particular,
I'd like to change my standard input and output (fd=0 and fd=1) to
binary so that I can create a filter program.  Right now, I do:

#include <fcntl.h>

.....

flag = fcntl(0, F_GETFL);
flag |= _FBINARY;
fcntl(0, F_SETFL, flag);
.....

but this doesn't seem to work.  As a matter of fact, flag seems to
retrieve some nonsensible value (perhaps the fd itself).

If this doesn't work, how much work-around do I need to do?  I read that
an open() with O_BINARY would do the trick for new files.  Perhaps I'll
give fdopen a try.  Does fcntl() work right now?

Thanks for any help.  Please email swift AT world DOT std DOT com.

Peter Lu
-
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