From 8c73a1a8a08651b00dfececcd108823f7980bf8b Mon Sep 17 00:00:00 2001 From: ollo Date: Wed, 24 Apr 2019 21:00:12 +0200 Subject: [PATCH] Removed original config.lua file, before the simulation one is integrated --- simulation/config.lua | 1 - simulation/src/de/c3ma/ollo/WS2812Simulation.java | 13 ++++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/simulation/config.lua b/simulation/config.lua index 5b81003..7c38a41 100644 --- a/simulation/config.lua +++ b/simulation/config.lua @@ -12,4 +12,3 @@ color4=string.char(tonumber(green2*0.2), 0, 0) colorBg=string.char(0,0,0) -- black is the default background color sntpserverhostname="ptbtime1.ptb.de" timezoneoffset=1 - diff --git a/simulation/src/de/c3ma/ollo/WS2812Simulation.java b/simulation/src/de/c3ma/ollo/WS2812Simulation.java index 08b80a2..e88976c 100644 --- a/simulation/src/de/c3ma/ollo/WS2812Simulation.java +++ b/simulation/src/de/c3ma/ollo/WS2812Simulation.java @@ -93,9 +93,16 @@ public class WS2812Simulation implements LuaSimulation { if (args.length >= 3) { File additionalFile = new File(args[2]); if (additionalFile.exists() && (simu.doFile != null)) { - - Files.copy(additionalFile.toPath(), new File(simu.doFile.getWorkingDirectory() - + File.separator + additionalFile.getName()).toPath()); + File targetFile = new File(simu.doFile.getWorkingDirectory() + + File.separator + additionalFile.getName()); + if (targetFile.exists()) { + if (targetFile.delete()) { + System.out.println("Removed original " + targetFile.getName() + ""); + } else { + System.err.println("Cannot removed original " + targetFile.getName() + ""); + } + } + Files.copy(additionalFile.toPath(), targetFile.toPath()); System.out.println("Integrate " + additionalFile.getName() + " into simulation"); } else { System.err.println("Script " + args[2] + " cannot be found");