2021-10-22 11:03:58 +02:00
|
|
|
package it.tdlight.jni.implementation_name.operating_system_name.cpu_architecture_name.version;
|
2020-10-10 00:18:33 +02:00
|
|
|
|
|
|
|
import java.lang.ClassLoader;
|
2020-10-29 13:39:16 +01:00
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.File;
|
2020-10-10 00:18:33 +02:00
|
|
|
|
|
|
|
public class LoadLibrary {
|
2020-10-29 13:39:16 +01:00
|
|
|
public static InputStream getLibraryAsStream() {
|
2021-10-22 11:03:58 +02:00
|
|
|
return LoadLibrary.class.getResourceAsStream("/libs/" + getOsName() + "/" + getArchName() + "/"
|
|
|
|
+ getFileName() + "/" + getVersionName() + getExtension());
|
2020-10-29 13:39:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private static String getOsName() {
|
2020-11-12 22:38:10 +01:00
|
|
|
return LoadLibrary.class.getPackage().getName().split("\\.")[4];
|
2020-10-29 13:39:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private static String getArchName() {
|
2020-11-12 22:38:10 +01:00
|
|
|
return LoadLibrary.class.getPackage().getName().split("\\.")[5];
|
2020-10-29 13:39:16 +01:00
|
|
|
}
|
|
|
|
|
2021-10-22 11:03:58 +02:00
|
|
|
private static String getVersionName() {
|
|
|
|
return LoadLibrary.class.getPackage().getName().split("\\.")[6];
|
|
|
|
}
|
|
|
|
|
2020-10-29 13:39:16 +01:00
|
|
|
private static String getFileName() {
|
|
|
|
return "tdjni";
|
|
|
|
}
|
|
|
|
|
|
|
|
private static String getExtension() {
|
|
|
|
switch (getOsName()) {
|
|
|
|
case "win":
|
|
|
|
return ".dll";
|
|
|
|
case "osx":
|
|
|
|
return ".dylib";
|
|
|
|
case "linux":
|
|
|
|
default:
|
|
|
|
return ".so";
|
|
|
|
}
|
2020-10-10 00:18:33 +02:00
|
|
|
}
|
|
|
|
}
|