aboutsummaryrefslogtreecommitdiff
path: root/lib/xwrap.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2018-04-03 22:11:43 -0500
committerRob Landley <rob@landley.net>2018-04-03 22:11:43 -0500
commit0043e99318bfade48c7a378997b691694b06edd0 (patch)
tree1e6218410f50fc72de43f8bba0d4d57852d89f0e /lib/xwrap.c
parent9448f8e57ed6ff85e756ec5e9545f99e6376e778 (diff)
downloadtoybox-0043e99318bfade48c7a378997b691694b06edd0.tar.gz
Factor out xtempfile()
Diffstat (limited to 'lib/xwrap.c')
-rw-r--r--lib/xwrap.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/xwrap.c b/lib/xwrap.c
index 74da0ed1..562cbaf4 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -377,6 +377,16 @@ int notstdio(int fd)
return fd;
}
+int xtempfile(char *name, char **tempname)
+{
+ int fd;
+
+ *tempname = xmprintf("%s%s", name, "XXXXXX");
+ if(-1 == (fd = mkstemp(*tempname))) error_exit("no temp file");
+
+ return fd;
+}
+
// Create a file but don't return stdin/stdout/stderr
int xcreate(char *path, int flags, int mode)
{