summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-03-02 20:13:26 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-03-02 20:13:26 -0800
commita4c7c97ed95a884ccf99cf8b3e0dfff715ef100a (patch)
tree12908a9e725ab752fee7e2c44fbda541eeacc178
parenta6b21fd386f88454f8c05a690ea309bec32c3857 (diff)
downloadtxr-a4c7c97ed95a884ccf99cf8b3e0dfff715ef100a.tar.gz
txr-a4c7c97ed95a884ccf99cf8b3e0dfff715ef100a.tar.bz2
txr-a4c7c97ed95a884ccf99cf8b3e0dfff715ef100a.zip
Support umask function.
* sysif.c (umask_wrap): New function. (sysif_init): Register umask intrinsic. * txr.1: Documented.
-rw-r--r--sysif.c14
-rw-r--r--txr.116
2 files changed, 30 insertions, 0 deletions
diff --git a/sysif.c b/sysif.c
index 7b072072..dd5f2409 100644
--- a/sysif.c
+++ b/sysif.c
@@ -668,6 +668,16 @@ val statf(val stream)
return stat_impl(stream, w_fstat, lit("fstat"));
}
+#if HAVE_SYS_STAT
+
+static val umask_wrap(val mask)
+{
+ (void) umask(c_num(mask));
+ return t;
+}
+
+#endif
+
#if HAVE_PIPE
static val pipe_wrap(void)
@@ -1475,4 +1485,8 @@ void sysif_init(void)
#if HAVE_POLL
reg_fun(intern(lit("poll"), user_package), func_n2o(poll_wrap, 1));
#endif
+
+#if HAVE_SYS_STAT
+ reg_fun(intern(lit("umask"), user_package), func_n1(umask_wrap));
+#endif
}
diff --git a/txr.1 b/txr.1
index 569864b8..63c2938b 100644
--- a/txr.1
+++ b/txr.1
@@ -35712,6 +35712,22 @@ For example
.code (logtest mode s-irgrp)
tests for the group read permission.
+.coNP Functions @ umask
+.synb
+.mets (umask << mask )
+.syne
+.desc
+The
+.code umask
+function provides access to the Unix C library function of the same name,
+which controls which permissions are denied
+when files are newly created. If
+.meta mask
+is a
+.code fixnum
+integer, this succeeds and returns
+.codn t .
+
.coNP Functions @, makedev @ minor and @ major
.synb
.mets (makedev < minor << major )