NativeLibrary: use System.mapLibraryName() instead of own implementation

This commit is contained in:
Karl Tauber
2022-03-19 11:07:46 +01:00
parent c63f4e9662
commit 301aae9b8e
2 changed files with 11 additions and 8 deletions

View File

@@ -136,7 +136,7 @@ class FlatWindowsNativeWindowBorder
String libraryPath = System.getProperty( FlatSystemProperties.NATIVE_LIBRARY_PATH );
if( libraryPath != null ) {
File libraryFile = new File( libraryPath, libraryName + ".dll" );
File libraryFile = new File( libraryPath, System.mapLibraryName( libraryName ) );
if( libraryFile.exists() )
return new NativeLibrary( libraryFile, true );
else

View File

@@ -143,16 +143,19 @@ public class NativeLibrary
}
}
/**
* Add prefix and suffix to library name.
* <ul>
* <li>Windows: libraryName + ".dll"
* <li>macOS: "lib" + libraryName + ".dylib"
* <li>Linux: "lib" + libraryName + ".so"
* </ul>
*/
private static String decorateLibraryName( String libraryName ) {
if( SystemInfo.isWindows )
return libraryName.concat( ".dll" );
String suffix = SystemInfo.isMacOS ? ".dylib" : ".so";
int sep = libraryName.lastIndexOf( '/' );
return (sep >= 0)
? libraryName.substring( 0, sep + 1 ) + "lib" + libraryName.substring( sep + 1 ) + suffix
: "lib" + libraryName + suffix;
? libraryName.substring( 0, sep + 1 ) + System.mapLibraryName( libraryName.substring( sep + 1 ) )
: System.mapLibraryName( libraryName );
}
private static void log( String msg, Throwable thrown ) {