summaryrefslogtreecommitdiffstats
path: root/stream.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-02-25 00:29:16 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-02-25 00:29:16 -0800
commitf46a5e3cdea380494554b0bd11782c8a4dabdc66 (patch)
tree365cb7401664f819e6dc5080d16581e303077517 /stream.c
parenta61708f6ca5df1dd17a6bad6a72003b08474ed6e (diff)
downloadtxr-f46a5e3cdea380494554b0bd11782c8a4dabdc66.tar.gz
txr-f46a5e3cdea380494554b0bd11782c8a4dabdc66.tar.bz2
txr-f46a5e3cdea380494554b0bd11782c8a4dabdc66.zip
* configure: Added feature tests for makedev, link/symlink/readlink,
mkdir and mknod. * eval.c (eval_init): Wrap #ifdefs around the registrations of the wrappers for these functions. * stream.c (mkdir_wrap): Wrap in #ifdef HAVE_MKDIR, and provide a Windows version if HAVE_MKDIR is missing, but HAVE_WINDOWS_H is true. (makedev_wrap, major_wrap, minor_wrap): Wrap with #if HAVE_MAKEDEV. (mknod): Use #if HAVE_MKNOD. (symlink_wrap, link_wrap, readlink_wrap): Wrap with #if HAVE_SYMLINK.
Diffstat (limited to 'stream.c')
-rw-r--r--stream.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/stream.c b/stream.c
index 7fde754a..190932d8 100644
--- a/stream.c
+++ b/stream.c
@@ -2378,7 +2378,7 @@ val rename_path(val from, val to)
return t;
}
-#if HAVE_SYS_STAT
+#if HAVE_MKDIR
val mkdir_wrap(val path, val mode)
{
char *u8path = utf8_dup_to(c_str(path));
@@ -2391,6 +2391,18 @@ val mkdir_wrap(val path, val mode)
return t;
}
+#elif HAVE_WINDOWS_H
+val mkdir_wrap(val path, val mode)
+{
+ int err = _wmkdir(c_str(path));
+
+ (void) mode;
+ if (err < 0)
+ uw_throwf(file_error_s, lit("mkdir ~a: ~a/~s"),
+ path, num(errno), string_utf8(strerror(errno)), nao);
+
+ return t;
+}
#endif
#if HAVE_UNISTD_H
@@ -2430,6 +2442,8 @@ val getcwd_wrap(void)
}
}
+#if HAVE_MAKEDEV
+
val makedev_wrap(val major, val minor)
{
return num(makedev(c_num(major), c_num(minor)));
@@ -2445,6 +2459,10 @@ val major_wrap(val dev)
return num(major(c_num(dev)));
}
+#endif
+
+#if HAVE_MKNOD
+
val mknod_wrap(val path, val mode, val dev)
{
char *u8path = utf8_dup_to(c_str(path));
@@ -2459,6 +2477,10 @@ val mknod_wrap(val path, val mode, val dev)
return t;
}
+#endif
+
+#if HAVE_SYMLINK
+
val symlink_wrap(val target, val to)
{
char *u8target = utf8_dup_to(c_str(target));
@@ -2516,6 +2538,8 @@ val readlink_wrap(val path)
#endif
+#endif
+
void stream_init(void)
{
protect(&std_input, &std_output, &std_debug, &std_error, &std_null, (val *) 0);