From 8913f8118dc9422e864812903389ed9b41d1893e Mon Sep 17 00:00:00 2001 From: r-ca Date: Tue, 9 Jan 2024 14:31:01 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=8C?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E3=81=97=E3=81=AA=E3=81=84=E5=A0=B4=E5=90=88?= =?UTF-8?q?=E3=81=AB=E4=BD=9C=E6=88=90=E3=81=99=E3=82=8B=E3=83=A1=E3=82=BD?= =?UTF-8?q?=E3=83=83=E3=83=89=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../one/nem/lacerta/source/file/FileManager.java | 2 ++ .../lacerta/source/file/impl/FileManagerImpl.java | 15 +++++++++++++++ 2 files changed, 17 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 deee58e7..3a088591 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 @@ -35,6 +35,8 @@ public interface FileManager { // Create FileManager createFile() throws IOException; FileManager createFile(String fileName) throws IOException; + FileManager createFileIfNotExist() throws IOException; + FileManager createFileIfNotExist(String fileName) throws IOException; FileManager createDirectory() throws IOException; FileManager createDirectory(String directoryName) throws IOException; FileManager createDirectoryIfNotExist() throws IOException; 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 01f0bc07..ed011f9c 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 @@ -190,6 +190,20 @@ public class FileManagerImpl implements FileManager { return this.createFile(); } + @Override + public FileManager createFileIfNotExist() throws IOException { + if (!this.isExist()) { + this.createFile(); + } + return this; + } + + @Override + public FileManager createFileIfNotExist(String fileName) throws IOException { + this.resolve(fileName); + return this.createFileIfNotExist(); + } + @Override public FileManager createDirectory() throws IOException { try { @@ -237,6 +251,7 @@ public class FileManagerImpl implements FileManager { transformer.transform(source, result); } catch (Exception e) { logger.error("saveXmlInternal", e.getMessage()); + e.printStackTrace(); throw new IOException("Failed to save xml"); } }