Permalink
Browse files

Fix mktemp call on Windows.

  • Loading branch information...
1 parent 84382f9 commit 6565f7a93229ddaac8b1c3fbb786f0eeb1fd9ff0 @djberg96 committed Jan 18, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/file/temp.rb
View
@@ -15,7 +15,7 @@ class File::Temp < File
attach_function :fclose, [:pointer], :int
attach_function :_fdopen, [:int, :string], :pointer
attach_function :_fileno, [:pointer], :int
- attach_function :_mktemp, [:string], :string
+ attach_function :_mktemp, [:pointer], :string
attach_function :_open, [:string, :int, :int], :int
attach_function :_open_osfhandle, [:long, :int], :int
attach_function :tmpnam, [:string], :string
@@ -113,7 +113,8 @@ def initialize(delete = true, template = 'rb_file_temp_XXXXXX')
omask = File.umask(077)
if File::ALT_SEPARATOR
- template = _mktemp(template)
+ char_ptr = FFI::MemoryPointer.from_string(template.dup)
+ template = _mktemp(char_ptr)
if template.nil?
raise SystemCallError, '_mktemp function failed: ' + get_error

0 comments on commit 6565f7a

Please sign in to comment.