X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fmain%2FConfiguration.java;h=b38e986042c02540c81307942a7fbfcb87926ecd;hb=437a0b9a2bc4c71877533b6e7137a1e964cb1748;hp=3322c035b2ac5e9f72c029e59df3bbc62ad391ea;hpb=c1a2ee01dcd487faeea245d8b90b628a0a816f0b;p=jSite.git diff --git a/src/de/todesbaum/jsite/main/Configuration.java b/src/de/todesbaum/jsite/main/Configuration.java index 3322c03..b38e986 100644 --- a/src/de/todesbaum/jsite/main/Configuration.java +++ b/src/de/todesbaum/jsite/main/Configuration.java @@ -113,9 +113,12 @@ public class Configuration { return false; } File lockFile = new File(lockFilename); - lockFile.deleteOnExit(); try { - return lockFile.createNewFile(); + boolean fileLocked = lockFile.createNewFile(); + if (fileLocked) { + lockFile.deleteOnExit(); + } + return fileLocked; } catch (IOException e) { /* ignore. */ } @@ -123,6 +126,13 @@ public class Configuration { } /** + * Tells the VM to remove the lock file on program exit. + */ + public void removeLockfileOnExit() { + new File(lockFilename).deleteOnExit(); + } + + /** * Reads the configuration from the file. */ private void readConfiguration() {