Heesob Park
9/17/2008 3:43:00 PM
2008/9/17 Daniel Berger <djberg96@gmail.com>:
> Hi everyone,
>
> I thought this would be a fun brain teaser. In short, I need a way to
> generate a semi-random file name based on a template on MS Windows.
> The motivation, in case you're wondering, is that I'm implementing a
> pure Ruby version of the mkstemp() function, which MS Windows does not
> support.
>
To be fair, MS Windows supports _mktemp() function.
mkstemp() can be defined as
def mkstemp(p)
require 'Win32API'
_mktemp = Win32API.new("msvcrt", "_mktemp", 'P', 'P')
File.open(_mktemp.call('my_template_XXXXXX'),File::CREAT|File::EXCL)
end
Regards,
Park Heesob