[Win32utils-devel] _mktemp on Windows

Daniel Berger djberg96 at gmail.com
Sat Jan 14 10:34:47 EST 2012


On Fri, Jan 13, 2012 at 9:42 PM, Heesob Park <phasis at gmail.com> wrote:
> Hi,
>
> 2012/1/14 Daniel Berger <djberg96 at gmail.com>:
>> Is it odd that calling _mktemp more than once in the same process doesn't work?
>>
>> require 'ffi'
>>
>> class Win
>>  extend FFI::Library
>>
>>  ffi_lib 'msvcrt'
>>  attach_function :_mktemp, [:string], :string
>>
>>  def self.mktemp
>>    5.times{ p _mktemp("rb_file_temp_XXXXXX") }
>>  end
>> end
>>
>> Win.mktemp
>>
>> # Output
>> "rb_file_temp_a03680"
>> nil
>> nil
>> nil
>> nil
>
> According to MSDN, _mktemp is deprecated; consider using _mktemp_s instead.
>
> Refer to http://msdn.microsoft.com/en-us/library/34wc6k1f(v=vs.80).aspx

True. I guess they were really serious about it this time. ;)

Unfortunately I'm not sure how to get at _mktemp_s with FFI using
mingw, since that function doesn't seem to be exported. Suggestions?

Regards,

Dan


More information about the win32utils-devel mailing list