[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: mkstemp
- From: Reuben Thomas <rrt@...>
- Date: Sun, 16 Apr 2006 01:22:41 +0100 (BST)
On Sat, 15 Apr 2006, Christian Vogler wrote:
tmpfile() is a better option; it's defined to do this stuff *for* you, so
you don't have to, and risk getting it wrong.
Problem is that in some libraries it does not. :-(
So, what can one do?
One can use functions that are well-defined, and re-use well-written
implementations from open source libraries where necessary and possible.
I suggest the following simplification of the Lua I/O library:
1. io.tmpfile should use umask on POSIX systems to get proper
permissions (as mkstemp does).
2. io.tmpfile should return the name as a second return value, so that
you can have:
function io.tmpname ()
local _, name = io.tmpfile ()
return name
end
if you really must.
3. io.tmpname should be removed. On a multi-tasking system it's bogus,
and its use should be discouraged; on a single-tasking system it can be
replaced if it really must be, as above.
--
http://rrt.sc3d.org/ | priest, n. an unpaid lawyer (q.v.)