feat: Добавлена поддержка Windows

- Потому что Илья сказал надо.
This commit is contained in:
MaXFeeD
2023-12-03 11:47:06 +03:00
parent 159e82e3aa
commit 4f68fcb310
@@ -126,34 +126,30 @@ public class InnerCoreServer {
} }
} }
static void getFolderRootFromUri(URI uri, String targetPath, Consumer<? super Path> action) throws IOException { static void getFolderRootFromUri(URI uri, String targetPath, Consumer<? super Path> action) {
Map<String, String> env = new HashMap<>(); Map<String, String> env = new HashMap<>();
env.put("create", "true"); env.put("create", "true");
try (final FileSystem fileSystem = FileSystems.newFileSystem(uri, env)) { try (final FileSystem fileSystem = FileSystems.newFileSystem(uri, env)) {
action.accept(fileSystem.getPath(targetPath)); action.accept(fileSystem.getPath(targetPath));
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException | IOException e) {
action.accept(Paths.get(uri.getPath())); action.accept(Paths.get(uri));
} }
} }
static void traverseResourcesFileSystem(String targetPath, Consumer<? super Path> action) static void traverseResourcesFileSystem(String targetPath, Consumer<? super Path> action)
throws URISyntaxException { throws URISyntaxException {
final URI uri = InnerCoreServer.class.getResource(targetPath).toURI(); final URI uri = InnerCoreServer.class.getResource(targetPath).toURI();
try { getFolderRootFromUri(uri, targetPath, folderRoot -> {
getFolderRootFromUri(uri, targetPath, folderRoot -> { try (final Stream<Path> walk = Files.walk(folderRoot)) {
try (final Stream<Path> walk = Files.walk(folderRoot)) { walk.forEach(childPath -> {
walk.forEach(childPath -> { if (Files.isRegularFile(childPath)) {
if (Files.isRegularFile(childPath)) { action.accept(folderRoot.relativize(childPath));
action.accept(folderRoot.relativize(childPath)); }
} });
}); } catch (IOException e) {
} catch (IOException e) { throw new RuntimeException(e);
throw new RuntimeException(e); }
} });
});
} catch (IOException e) {
throw new RuntimeException(e);
}
} }
static void unpackResources(String targetPath, String outputPath) throws URISyntaxException { static void unpackResources(String targetPath, String outputPath) throws URISyntaxException {