From bd4ec49671b07f93883c7e0c9142125525731714 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 9 Jul 2000 05:29:51 +0000 Subject: * cygwin.din: Export _getmode and getmode to allow querying of binary state of an fd. * external.cc (cygwin_internal): Add handling of perfile_table setting. * fhandler.cc (perfile_table): New global. (fhandler_base::get_default_fmode): New method to return a file's default mode based on its name. (fhandler_base::open): Use get_default_mode method to determine a file's mode. Record file mode in file flags. * fhandler.h (fhandler_base): Declare get_default_fmode * syscalls.cc (getmode): New function. * sys/cygwin.h (__cygwin_perfile): New structure. (cygwin_getinfo_types): Move outside of WINVER conditional. (per_process): Move inside of WINVER conditional. --- winsup/cygwin/syscalls.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'winsup/cygwin/syscalls.cc') diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index b0251bf..9594a49 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1494,11 +1494,22 @@ setmode_helper (FILE *f) return 0; } +extern "C" int +getmode (int fd) +{ + if (dtable.not_open (fd)) + { + set_errno (EBADF); + return -1; + } + + return dtable[fd]->get_flags () & (O_BINARY | O_TEXT); +} + /* Set a file descriptor into text or binary mode, returning the previous mode. */ -extern "C" -int +extern "C" int setmode (int fd, int mode) { if (dtable.not_open (fd)) -- cgit v1.1