diff options
author | Christopher Faylor <me@cgf.cx> | 2000-07-09 05:29:51 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-07-09 05:29:51 +0000 |
commit | bd4ec49671b07f93883c7e0c9142125525731714 (patch) | |
tree | 49c4d2e87d54048f97bea742896acb5b348ffda1 /winsup/cygwin/syscalls.cc | |
parent | 85219b356e249702b845cf667462584945b1735b (diff) | |
download | newlib-bd4ec49671b07f93883c7e0c9142125525731714.zip newlib-bd4ec49671b07f93883c7e0c9142125525731714.tar.gz newlib-bd4ec49671b07f93883c7e0c9142125525731714.tar.bz2 |
* 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.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r-- | winsup/cygwin/syscalls.cc | 15 |
1 files changed, 13 insertions, 2 deletions
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)) |