diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-05-26 22:53:51 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-05-26 22:53:51 -0700 |
commit | e23478755d418e5f80384dbfa2536f2aaa3c888b (patch) | |
tree | 104c35ac486eb0d312835616096e5036152558af /stream.c | |
parent | e48572f574e24bae076c909c066f42c4d1f3b3aa (diff) | |
download | txr-e23478755d418e5f80384dbfa2536f2aaa3c888b.tar.gz txr-e23478755d418e5f80384dbfa2536f2aaa3c888b.tar.bz2 txr-e23478755d418e5f80384dbfa2536f2aaa3c888b.zip |
gzio: support more modes in open-file.
* gzio.c (w_gzopen_mode): Use w_open_mode if available, in order
to support most of the flags (including "x" which Zlib has,
but which we are not passing through).
* stream.c (w_open_mode): New function formed from w_fopen_mode
content.
(w_fopen_mode): Call w_open_mode.
* stream.c (w_open_mode): Declared.
Diffstat (limited to 'stream.c')
-rw-r--r-- | stream.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -1127,10 +1127,9 @@ static struct strm_ops stdio_ops = static struct strm_ops stdio_sock_ops; #endif -static FILE *w_fopen_mode(const wchar_t *wname, const wchar_t *mode, - const struct stdio_mode m) -{ #if HAVE_FCNTL +int w_open_mode(const wchar_t *wname, const struct stdio_mode m) +{ char *name = utf8_dup_to(wname); size_t nsiz = strlen(name) + 1; int flags = (if3(m.read && m.write, O_RDWR, 0) | @@ -1150,6 +1149,15 @@ static FILE *w_fopen_mode(const wchar_t *wname, const wchar_t *mode, fd = open(stkname, flags, 0666); sig_restore_enable; + return fd; +} +#endif + +static FILE *w_fopen_mode(const wchar_t *wname, const wchar_t *mode, + const struct stdio_mode m) +{ +#if HAVE_FCNTL + int fd = w_open_mode(wname, m); return (fd < 0) ? NULL : w_fdopen(fd, mode); #else /* TODO: detect if fopen supports "x" in mode */ |