Sha256: 057762500b6f354049eff5238514377046c9cad5aa23fe254eefbba1cf25e049
Contents?: true
Size: 631 Bytes
Versions: 7
Compression:
Stored size: 631 Bytes
Contents
require 'ffi' module EightThree extend FFI::Library ffi_lib 'kernel32' ffi_convention :stdcall =begin DWORD WINAPI GetShortPathName( __in LPCTSTR lpszLongPath, __out LPTSTR lpszShortPath, __in DWORD cchBuffer ); =end attach_function :path_to_8_3, :GetShortPathNameA, [:pointer, :pointer, :uint], :uint def self.convert_path_to_8_3 path out = FFI::MemoryPointer.new 256 # bytes path_to_8_3(path, out, out.size) out = out.get_string 0 if out.size == 0 raise 'unable to convert--probably file does not exist yet ' + path else out end end end
Version data entries
7 entries across 7 versions & 2 rubygems