shithub: mc

Download patch

ref: 5077c6c598ab3d5eed864fca827ed45b5abdb66b
parent: 2b755a0e6bffb0f75f9b0f1433cfe55bd7499606
author: Andrew Chambers <andrewchamberss@gmail.com>
date: Mon Feb 8 12:37:07 EST 2016

add mktempat to std

--- a/lib/std/mktemp.myr
+++ b/lib/std/mktemp.myr
@@ -14,6 +14,7 @@
 
 pkg std =
 	const mktemp	: (base : byte[:], opt : fdopt, mode : int64 -> std.result((fd, byte[:]), errno))
+	const mktempat	: (dir : byte[:], base : byte[:], opt : fdopt, mode : int64 -> std.result((fd, byte[:]), errno))
 	const mktemppath	: (base : byte[:] -> byte[:])
 ;;
 
@@ -20,12 +21,19 @@
 const Retries = 100
 
 const mktemp = {base, opt, mode
-	var tmpdir, path
+	var tmpdir
 
 	match std.getenv("TMPDIR")
 	| `std.Some d:	tmpdir = d
 	| `std.None:	tmpdir = "/tmp"
 	;;
+	
+	-> mktempat(tmpdir, base, opt, mode)
+	
+}
+
+const mktempat = {tmpdir, base, opt, mode
+	var path
 
 	for var i = 0; i < Retries; i++
 		path = randpath(tmpdir, base)