diff options
author | Kaz Kyheku <kaz@kylheku.com> | 2020-01-15 21:46:40 -0800 |
---|---|---|
committer | Kaz Kyheku <kaz@kylheku.com> | 2020-01-15 21:46:40 -0800 |
commit | fa62e08dc6e915422c0dd99c18e050182e5e694f (patch) | |
tree | d9d2e38a96f3c7e8c021c500f661409e9641f70d /sysif.c | |
parent | 586a4afc8f9d5616fdf21c471a772391e574bc43 (diff) | |
download | txr-fa62e08dc6e915422c0dd99c18e050182e5e694f.tar.gz txr-fa62e08dc6e915422c0dd99c18e050182e5e694f.tar.bz2 txr-fa62e08dc6e915422c0dd99c18e050182e5e694f.zip |
fstat: take fd argument.
* sysif.c (get_fd): Make available under HAVE_SYS_STAT.
(fstat): Allow fd or stream argument using get_fd.
* txr.1: Documented.
Diffstat (limited to 'sysif.c')
-rw-r--r-- | sysif.c | 19 |
1 files changed, 7 insertions, 12 deletions
@@ -449,8 +449,7 @@ static val mknod_wrap(val path, val mode, val dev) #endif -#if HAVE_CHMOD - +#if HAVE_CHMOD || HAVE_SYS_STAT static int get_fd(val stream, val self) { val fd_in = if3(integerp(stream), stream, stream_get_prop(stream, fd_k)); @@ -467,6 +466,9 @@ static int get_fd(val stream, val self) return c_int(fd_in, self); } +#endif + +#if HAVE_CHMOD static val chmod_wrap(val target, val mode) { @@ -790,16 +792,9 @@ static int w_lstat(val wpath, struct stat *buf) static int w_fstat(val stream, struct stat *buf) { - val fd = stream_get_prop(stream, fd_k); - - if (fd) { - int res = fstat(c_num(fd), buf); - return res; - } - - uw_throwf(file_error_s, - lit("cannot fstat stream ~s: it has no :fd property"), - stream, nao); + val self = lit("fstat"); + int fd = get_fd(stream, self); + return fstat(fd, buf); } #endif |