From ec72b900200763c36866e14094312502b561e7f7 Mon Sep 17 00:00:00 2001 From: Francois G Date: Sat, 25 Feb 2023 20:27:59 +0100 Subject: [PATCH] Make source code file name more unique --- src/be/jeffcheasey88/peeratcode/routes/PuzzleResponse.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/be/jeffcheasey88/peeratcode/routes/PuzzleResponse.java b/src/be/jeffcheasey88/peeratcode/routes/PuzzleResponse.java index 84b2575..d613efb 100644 --- a/src/be/jeffcheasey88/peeratcode/routes/PuzzleResponse.java +++ b/src/be/jeffcheasey88/peeratcode/routes/PuzzleResponse.java @@ -1,9 +1,11 @@ package be.jeffcheasey88.peeratcode.routes; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -59,8 +61,9 @@ public class PuzzleResponse implements Response { } private void saveSourceCode(ReceivedResponse received, Player player) throws IOException { - Path path = Paths.get(player.getPathToSourceCode() + received.getFileName()); + Path path = Paths.get(String.format("%s/puz%04d-%s", player.getPathToSourceCode(), received.getPuzzleId(), received.getFileName())); Files.write(path, received.getSourceCode()); + } @Override