MCPcopy Index your code
hub / github.com/java-native-access/jna / findLibraryPath

Method findLibraryPath

src/com/sun/jna/NativeLibrary.java:732–769  ·  view source on GitHub ↗

Use standard library search paths to find the library.

(String libName, Collection<String> searchPath)

Source from the content-addressed store, hash-verified

730
731 /** Use standard library search paths to find the library. */
732 private static String findLibraryPath(String libName, Collection<String> searchPath) {
733
734 //
735 // If a full path to the library was specified, don't search for it
736 //
737 if (new File(libName).isAbsolute()) {
738 return libName;
739 }
740
741 //
742 // Get the system name for the library (e.g. libfoo.so)
743 //
744 String name = mapSharedLibraryName(libName);
745
746 // Search in the JNA paths for it
747 for (String path : searchPath) {
748 File file = new File(path, name);
749 if (file.exists()) {
750 return file.getAbsolutePath();
751 }
752 if (Platform.isMac()) {
753 // Native libraries delivered via JNLP class loader
754 // may require a .jnilib extension to be found
755 if (name.endsWith(".dylib")) {
756 file = new File(path, name.substring(0, name.lastIndexOf(".dylib")) + ".jnilib");
757 if (file.exists()) {
758 return file.getAbsolutePath();
759 }
760 }
761 }
762 }
763
764 //
765 // Default to returning the mapped library name and letting the system
766 // search for it
767 //
768 return name;
769 }
770
771 /** Similar to {@link System#mapLibraryName}, except that it maps to
772 standard shared library formats rather than specifically JNI formats.

Callers 1

loadLibraryMethod · 0.95

Calls 2

mapSharedLibraryNameMethod · 0.95
isMacMethod · 0.95

Tested by

no test coverage detected