views:

63

answers:

0

Does anyone have a code sample that shows how to use the Win32 function CopyFileExW in ruby? The difficulty i am having is declaring the 'ProgressRoutine' call back function correctly without getting a segfault.

I can use CopyFileW without issue, but CopyFileExW is causing grief.

require 'windows/error'
require 'windows/wide_string'
require 'windows/api'
require 'windows/file'

module WinUtils
    include Windows::File
    include Windows::Error

    def cp(s,d)
        s = WideString.new(s)
        d = WideString.new(d)

        raise get_last_error unless CopyFileW(s, d, false)
    end
end

include WinUtils
cp('filea', 'fileb')