From 88cd58f9204e2e8e8010fb6ccb5c53ad840ebd32 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 8 Jan 2024 11:38:05 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=84=E3=81=8F=E3=81=A4=E3=81=8B=E3=81=AE?= =?UTF-8?q?=E3=83=A1=E3=82=BD=E3=83=83=E3=83=89=E3=81=A7=E5=AF=BE=E5=BF=9C?= =?UTF-8?q?=E3=81=99=E3=82=8B=E5=BC=95=E6=95=B0=E3=82=92=E5=A2=97=E3=82=84?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nem/lacerta/source/file/FileManager.java | 3 ++ .../source/file/impl/FileManagerImpl.java | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/source/src/main/java/one/nem/lacerta/source/file/FileManager.java b/source/src/main/java/one/nem/lacerta/source/file/FileManager.java index 9cc9e503..d69d9972 100644 --- a/source/src/main/java/one/nem/lacerta/source/file/FileManager.java +++ b/source/src/main/java/one/nem/lacerta/source/file/FileManager.java @@ -16,7 +16,9 @@ public interface FileManager { void backRootDir(); //cd / List getList(); void createDir(String dirName); + void createDir(Path path); void removeDir(String dirName); + void removeDir(Path path); File createFile(String fileName); void removeFile(String fileName); @@ -25,6 +27,7 @@ public interface FileManager { boolean isExist(String fileName); void autoCreateDir(Path path); + void autoCreateDir(String dirName); void autoCreateToCurrentDir(); diff --git a/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java b/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java index 4abdc172..73a126ec 100644 --- a/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java +++ b/source/src/main/java/one/nem/lacerta/source/file/impl/FileManagerImpl.java @@ -102,12 +102,29 @@ public class FileManagerImpl implements FileManager { } } + @Override + public void createDir(Path path) { + logger.debug("createDir", "called"); + try { + Files.createDirectory(path); + } catch (IOException e) { + e.printStackTrace(); + } + } + @Override public void removeDir(String dirName) { logger.debug("removeDir", "called"); currentDir.resolve(dirName).toFile().delete(); // TODO-rca: エラーハンドリング } + @Override + public void removeDir(Path path) { + logger.debug("removeDir", "called"); + path.toFile().delete(); // TODO-rca: エラーハンドリング + } + + @Override public File createFile(String fileName) { logger.debug("createFile", "called"); @@ -144,6 +161,18 @@ public class FileManagerImpl implements FileManager { } } + @Override + public void autoCreateDir(String dirName) { + logger.debug("autoCreateDir", "called"); + if (!Files.exists(currentDir.resolve(dirName))) { + try { + Files.createDirectories(currentDir.resolve(dirName)); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + @Override public void autoCreateToCurrentDir() { logger.debug("autoGenerateToCurrentDir", "called");