diff options
author | sof <unknown> | 1999-09-19 19:27:10 +0000 |
---|---|---|
committer | sof <unknown> | 1999-09-19 19:27:10 +0000 |
commit | 7bef35dc53e91566f1bb8c51cce5ef87123ac4df (patch) | |
tree | 9e7164a63ca6907270b0d342066a4aeb2664e493 /ghc/lib/std/cbits/setBinaryMode.c | |
parent | 72ed2d6ddf7122ac66f9f08713d5b385c3b91f8b (diff) | |
download | haskell-7bef35dc53e91566f1bb8c51cce5ef87123ac4df.tar.gz |
[project @ 1999-09-19 19:27:10 by sof]
IOExts.hSetBinaryMode wrapper
Diffstat (limited to 'ghc/lib/std/cbits/setBinaryMode.c')
-rw-r--r-- | ghc/lib/std/cbits/setBinaryMode.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/ghc/lib/std/cbits/setBinaryMode.c b/ghc/lib/std/cbits/setBinaryMode.c new file mode 100644 index 0000000000..641e999a55 --- /dev/null +++ b/ghc/lib/std/cbits/setBinaryMode.c @@ -0,0 +1,38 @@ +/* + * (c) The GRASP/AQUA Project, Glasgow University, 1999 + * + * $Id: setBinaryMode.c,v 1.1 1999/09/19 19:27:10 sof Exp $ + * + * hSetBinaryMode runtime support + */ + +#include "Rts.h" +#include "stgio.h" + +#ifdef HAVE_FCNTL_H +#include <fcntl.h> +#endif + +#ifdef _WIN32 +#include <io.h> +#endif + +StgInt +setBinaryMode__(ptr,flg) +StgForeignPtr ptr; +StgInt flg; +{ + IOFileObject* fo = (IOFileObject*)ptr; + int rc; + + rc = flushBuffer(ptr); + if (rc < 0) return rc; + +#ifdef _WIN32 + setmode ( fo->fd, flg ? O_BINARY : O_TEXT ); +#endif + rc = (fo->flags & FILEOBJ_BINARY ? 1 : 0); + fo->flags = fo->flags & (flg ? FILEOBJ_BINARY : ~FILEOBJ_BINARY); + + return rc; +} |