123456789_123456789_123456789_123456789_123456789_

Class: RubyInstaller::Build::DllDirectory

Do not use. This class is for internal use only.
Relationships & Source Files
Namespace Children
Exceptions:
Inherits: Object
Defined in: lib/ruby_installer/build/dll_directory.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

  • #remove

    This method removes the given directory from the active DLL search paths.

Class Method Details

.add_dll_directory_winapi(path)

See additional method definition at line 93.

Raises:

[ GitHub ]

  
# File 'lib/ruby_installer/build/dll_directory.rb', line 102

def self.add_dll_directory_winapi(path)
  strutf16 = (path + "\0").encode(Encoding::UTF_16LE)
  strptr = Fiddle::Pointer.malloc(strutf16.bytesize, Fiddle::RUBY_FREE)
  strptr[0, strptr.size] = strutf16
  handle = AddDllDirectory.call(strptr)
  raise WinApiError, "AddDllDirectory failed for #{path}" if handle.null?
  handle
end

.set_default_dll_directories_winapi

Set default search paths to LOAD_LIBRARY_SEARCH_DEFAULT_DIRS to include path added by add_dll_directory_winapi() and exclude paths set per PATH environment variable.

Raises:

[ GitHub ]

  
# File 'lib/ruby_installer/build/dll_directory.rb', line 88

def self.set_default_dll_directories_winapi
  raise WinApiError, "SetDefaultDllDirectories failed" if SetDefaultDllDirectories.call(0x00001000)==0
end

.set_defaults

Set default search paths to the application directory (where ruby.exe resides) and to paths that are added per DllDirectory.new(). It disables the PATH environment variable for DLL search.

This method is usually called while ::RubyInstaller startup.

[ GitHub ]

  
# File 'lib/ruby_installer/build/dll_directory.rb', line 51

def self.set_defaults
  if @@dll_directory_mechanism != :path
    set_default_dll_directories_winapi
  end
end

Instance Attribute Details

#path (readonly)

[ GitHub ]

  
# File 'lib/ruby_installer/build/dll_directory.rb', line 45

attr_reader :path

Instance Method Details

#remove

This method removes the given directory from the active DLL search paths.

[ GitHub ]

  
# File 'lib/ruby_installer/build/dll_directory.rb', line 110

def remove
  if @handle
    raise WinApiError, "RemoveDllDirectory failed for #{@path}" if RemoveDllDirectory.call(@handle) == 0
  elsif @path
    ENV['PATH'] = ENV['PATH'].sub(@path + ";", "")
  end
end