Get the library paths from ldconfig cache. Tested against ldconfig 2.13.
()
| 1016 | * Get the library paths from ldconfig cache. Tested against ldconfig 2.13. |
| 1017 | */ |
| 1018 | private static ArrayList<String> getLinuxLdPaths() { |
| 1019 | ArrayList<String> ldPaths = new ArrayList<>(); |
| 1020 | Process process = null; |
| 1021 | BufferedReader reader = null; |
| 1022 | try { |
| 1023 | process = Runtime.getRuntime().exec("/sbin/ldconfig -p"); |
| 1024 | reader = new BufferedReader(new InputStreamReader(process.getInputStream())); |
| 1025 | String buffer; |
| 1026 | while ((buffer = reader.readLine()) != null) { |
| 1027 | int startPath = buffer.indexOf(" => "); |
| 1028 | int endPath = buffer.lastIndexOf('/'); |
| 1029 | if (startPath != -1 && endPath != -1 && startPath < endPath) { |
| 1030 | String path = buffer.substring(startPath + 4, endPath); |
| 1031 | if (!ldPaths.contains(path)) { |
| 1032 | ldPaths.add(path); |
| 1033 | } |
| 1034 | } |
| 1035 | } |
| 1036 | } catch (Exception e) { |
| 1037 | } finally { |
| 1038 | if(reader != null) { |
| 1039 | try { |
| 1040 | reader.close(); |
| 1041 | } catch (IOException e) { |
| 1042 | } |
| 1043 | } |
| 1044 | if(process != null) { |
| 1045 | try { |
| 1046 | process.waitFor(); |
| 1047 | } catch (InterruptedException e) { |
| 1048 | } |
| 1049 | } |
| 1050 | } |
| 1051 | return ldPaths; |
| 1052 | } |
| 1053 | |
| 1054 | private static final class NativeLibraryDisposer implements Runnable { |
| 1055 |