From 4f68fcb310cf806002b53b555ece09fbe0f83b7e Mon Sep 17 00:00:00 2001 From: MaXFeeD Date: Sun, 3 Dec 2023 11:47:06 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6?= =?UTF-8?q?=D0=BA=D0=B0=20Windows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Потому что Илья сказал надо. --- .../java/com/reider745/InnerCoreServer.java | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/reider745/InnerCoreServer.java b/src/main/java/com/reider745/InnerCoreServer.java index bd94ba6f..1ba863d0 100644 --- a/src/main/java/com/reider745/InnerCoreServer.java +++ b/src/main/java/com/reider745/InnerCoreServer.java @@ -126,34 +126,30 @@ public class InnerCoreServer { } } - static void getFolderRootFromUri(URI uri, String targetPath, Consumer action) throws IOException { + static void getFolderRootFromUri(URI uri, String targetPath, Consumer action) { Map env = new HashMap<>(); env.put("create", "true"); try (final FileSystem fileSystem = FileSystems.newFileSystem(uri, env)) { action.accept(fileSystem.getPath(targetPath)); - } catch (IllegalArgumentException e) { - action.accept(Paths.get(uri.getPath())); + } catch (IllegalArgumentException | IOException e) { + action.accept(Paths.get(uri)); } } static void traverseResourcesFileSystem(String targetPath, Consumer action) throws URISyntaxException { final URI uri = InnerCoreServer.class.getResource(targetPath).toURI(); - try { - getFolderRootFromUri(uri, targetPath, folderRoot -> { - try (final Stream walk = Files.walk(folderRoot)) { - walk.forEach(childPath -> { - if (Files.isRegularFile(childPath)) { - action.accept(folderRoot.relativize(childPath)); - } - }); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); - } catch (IOException e) { - throw new RuntimeException(e); - } + getFolderRootFromUri(uri, targetPath, folderRoot -> { + try (final Stream walk = Files.walk(folderRoot)) { + walk.forEach(childPath -> { + if (Files.isRegularFile(childPath)) { + action.accept(folderRoot.relativize(childPath)); + } + }); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); } static void unpackResources(String targetPath, String outputPath) throws URISyntaxException {