# File lib/nice-ffi/library.rb, line 68 def load_library( names, search_paths=NiceFFI::PathSet::DEFAULT ) names = [names] unless names.kind_of? Array paths = search_paths.find( *names ) # Try just the plain library name(s), as last resort. paths += names # Try loading each path until one works. loaded = paths.find { |path| begin self.module_eval { ffi_lib path } rescue LoadError false else true end } if loaded.nil? # Oops, none of them worked. pretty_names = if names.size == 1 names[0] else names[0..-2].join(", ") + ", or " + names[-1] end raise( LoadError, "Could not load #{pretty_names}." ) else # Return the one that did work return loaded end end