shithub: mc

Download patch

ref: 5a7ad6eb2cb497076f909e54e14d42f65eb89ff9
parent: d16071e98377886ce745978334cf73767c85d96c
parent: 5077c6c598ab3d5eed864fca827ed45b5abdb66b
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Feb 10 06:36:45 EST 2016

Merge branch 'mktempat' of https://github.com/andrewchambers/mc

--- 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)