Skip to content

Commit

Permalink
Don't assume file path delimiter when copying template files
Browse files Browse the repository at this point in the history
Instead of manually removing the prefix to the template root, use
Path.relativize to get the relative name of template files.
  • Loading branch information
arvidfm committed May 15, 2017
1 parent a2f1504 commit 64f629a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/src/iristk/system/IrisUtils.java
Expand Up @@ -14,6 +14,8 @@
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
Expand Down Expand Up @@ -184,12 +186,12 @@ public static void createFromTemplate(String templateName, String name, String p
throw new IOException(packagePath + " already exists");
String templateIdLC = "$" + StringUtils.lcFirst(templateName) + "$";
String templateIdUC = "$" + StringUtils.ucFirst(templateName) + "$";
String templRoot = props.getProperty("templatePath");
for (String filen : FileFinder.findAll(templRoot)) {
Path templRoot = Paths.get(props.getProperty("templatePath"));
for (String filen : FileFinder.findAll(templRoot.toString())) {
File inputFile = new File(filen);
if (inputFile.getName().equals("template.properties"))
continue;
String entryName = filen.replace(templRoot + "\\", "");
String entryName = templRoot.relativize(Paths.get(filen)).toString();
entryName = entryName.replace(templateIdLC, StringUtils.lcFirst(name));
entryName = entryName.replace(templateIdUC, StringUtils.ucFirst(name));
File targetFile = new File(packagePath, entryName);
Expand Down

0 comments on commit 64f629a

Please sign in to comment.