From 208319c21734bbb829fd6b8e2bc9da819b454bad Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 23 Jan 2020 22:06:52 -0800 Subject: New function: mkfifo. * configure: detect mkfifo. (sysif_init): Register mkfifo intrinsic. * txr.1: Documented. --- sysif.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'sysif.c') diff --git a/sysif.c b/sysif.c index 4fd4657f..dbaf8e59 100644 --- a/sysif.c +++ b/sysif.c @@ -455,6 +455,27 @@ static val mknod_wrap(val path, val mode, val dev) #endif +#if HAVE_MKFIFO + +static val mkfifo_wrap(val path, val mode) +{ + cnum cmode = c_num(mode); + char *u8path = utf8_dup_to(c_str(path)); + int err = mkfifo(u8path, cmode); + free(u8path); + + if (err < 0) { + int eno = errno; + uw_throwf(errno_to_file_error(eno), lit("mknod ~a ~a: ~d/~s"), + path, mode, num(eno), + string_utf8(strerror(eno)), nao); + } + + return t; +} + +#endif + #if HAVE_CHMOD || HAVE_SYS_STAT || HAVE_FILE_STAMP_CHANGE static int get_fd(val stream, val self) { @@ -2057,6 +2078,10 @@ void sysif_init(void) reg_fun(intern(lit("mknod"), user_package), func_n3o(mknod_wrap, 2)); #endif +#if HAVE_MKFIFO + reg_fun(intern(lit("mkfifo"), user_package), func_n2(mkfifo_wrap)); +#endif + #if HAVE_CHMOD reg_fun(intern(lit("chmod"), user_package), func_n2(chmod_wrap)); #endif -- cgit v1.2.3