module FFI::Module::Loader

Public Instance Methods

ffi_find_library_path(libname, search_paths) click to toggle source
# File lib/ffi/module/loader.rb, line 28
def ffi_find_library_path(libname, search_paths)
        search_paths.each do |search_path|
                full_path = File.join(search_path, libname)
                if File.exist?(full_path)
                        return full_path
                end
        end
        
        return nil
end
ffi_load(name, search_paths: nil, **options) click to toggle source
# File lib/ffi/module/loader.rb, line 39
def ffi_load(name, search_paths: nil, **options)
        # Try to load the library directly:
        return true if ffi_open_library(name, **options)
        
        # If that fails, try to load it from the specified search paths:
        if search_paths&.any?
                name = FFI.map_library_name(name)
                
                if path = ffi_find_library_path(name, search_paths)
                        return true if ffi_open_library(path, **options)
                end
        end
        
        return nil
end
ffi_load_failure(message) click to toggle source
# File lib/ffi/module/loader.rb, line 55
def ffi_load_failure(message)
        raise LoadError, message
end