| 67 | } |
| 68 | |
| 69 | @ApiStatus.Internal |
| 70 | @SneakyThrows |
| 71 | public static File _extract(String resourcePath, String fileName, File tempDir) { |
| 72 | File file; |
| 73 | URL url = Library.class.getResource(resourcePath + fileName); |
| 74 | if (url == null) { |
| 75 | file = new File(fileName); |
| 76 | if (!file.exists()) |
| 77 | throw new IllegalArgumentException("Library file " + fileName + " not found in " + resourcePath); |
| 78 | } else if (url.getProtocol() == "file") { |
| 79 | file = new File(url.toURI()); |
| 80 | } else { |
| 81 | file = new File(tempDir, fileName); |
| 82 | if (!file.exists()) { |
| 83 | if (!tempDir.exists()) |
| 84 | tempDir.mkdirs(); |
| 85 | try (InputStream is = url.openStream()) { |
| 86 | Files.copy(is, file.toPath(), StandardCopyOption.REPLACE_EXISTING); |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | if ("true".equals(System.getenv("JWM_VERBOSE"))) |
| 91 | System.out.println("Loading " + file); |
| 92 | return file; |
| 93 | } |
| 94 | |
| 95 | @ApiStatus.Internal public static native void _nAfterLoad(); |
| 96 | } |