Module: RobustExcelOle::Cygwin

Defined in:
lib/robust_excel_ole/cygwin.rb

Class Method Summary collapse

Class Method Details

.cygpath(options, path) ⇒ Object

:nodoc:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/robust_excel_ole/cygwin.rb', line 14

def cygpath(options, path) # :nodoc:
  absolute = shortname = false
  func = nil
  options.delete(" \t-").chars do |opt|
    case opt
    when 'u'
      func = [@conv_to_full_posix_path, @conv_to_posix_path]
    when 'w'
      func = [@conv_to_full_win32_path, @conv_to_win32_path]
    when 'a'
      absolute = true
    when 's'
      shortname = true
    end
  end
  raise 'first argument must contain -u or -w' if func.nil?

  func = absolute ? func[0] : func[1]
  buf = "\0" * 300
  raise 'cannot convert path name' if func.Call(path, buf) == -1

  buf.delete!("\0")
  buf
end