lua-users home
lua-l archive

Re: os.tmpname()

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


See io.tmpfile in Lua 5.1 beta.
Also, take a look at luaconf.h; if you define LUA_USE_POSIX (or LUA_USE_MKSTEMP), it will use mkstemp instead of tmpnam.
On 29-Nov-05, at 6:48 PM, Chris Marrin wrote:
Frederico Rodrigues Abraham wrote:
 well i solved it using tmpname(NULL,NULL)... it considers the
temporary directory of the system.
 when i use tmpnam() on windows on a non-writable root, the filename
generated (\something) is not writable...
 i guess it's an implementation bug
FYI, tmpnam is considered a very bad function to use. If two processes or threads use it at the same time, it can generate a duplicate filename. It is much better to use tmpfile() which returns a FILE* directly, so it can be atomic and avoid duplicate names. It works on both win32 and Linux, and I assume on most other Unices (including Mac OSX). That might be a better function to wrap. It has the added benefit of deleting the file automatically when you close it!
--
chris marrin ,"",ドル
chris@marrin.com b` $ ,,.
 mP b' , 1$'
 ,.` ,b` ,` :$$'
 ,|` mP ,` ,mm
 ,b" b" ,` ,mm m$$ ,m ,`P$$
 m$` ,b` .` ,mm ,'|$P ,|"1$` ,b$P ,` :1ドル
 b$` ,$: :,`` |$$ ,` $$` ,|` ,$,,ドル`"$$ .` :$|
b$| _m$`,:` :1ドル ,` ,$Pm|` ` :$,ドル..;"' |$:
P$b, _;b$$b1ドル" |$$ ,` ,$$" ``' $$
 ```"```'" `"` `""` ""` ,P`
"As a general rule,don't solve puzzles that open portals to Hell"'

AltStyle によって変換されたページ (->オリジナル) /