add ability to not overwrite some resources like config files

This commit is contained in:
Zlatin Balevsky
2021-03-19 02:46:56 +00:00
parent 446b87d71c
commit 52dbe4c90a
3 changed files with 9 additions and 4 deletions

View File

@ -61,6 +61,7 @@ public class PackageLauncher {
String []split = description.split(",");
String url = split[0];
String target = split[1];
boolean overwrite = Boolean.parseBoolean(split[2]);
var resource = PackageLauncher.class.getClassLoader().getResourceAsStream(url);
@ -75,7 +76,8 @@ public class PackageLauncher {
else if (!targetDir.isDirectory())
throw new Exception(targetDir + " exists but not a directory. Please get it out of the way");
Files.copy(resource, targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
if (!targetFile.exists() || overwrite)
Files.copy(resource, targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
}