diff --git a/yamf-core/src/main/java/nz/ac/wgtn/yamf/commons/Files.java b/yamf-core/src/main/java/nz/ac/wgtn/yamf/commons/Files.java new file mode 100644 index 0000000..8010477 --- /dev/null +++ b/yamf-core/src/main/java/nz/ac/wgtn/yamf/commons/Files.java @@ -0,0 +1,17 @@ +package nz.ac.wgtn.yamf.commons; + +import java.io.File; +import java.nio.file.Path; + +/** + * File related utilities. + * @author jens dietrich + */ +public class Files { + public static String relativize(File file, File baseFolder) { + Path pathAbsolute = file.toPath(); + Path pathBase = baseFolder.toPath(); + return pathBase.relativize(pathAbsolute).toString(); + } + +} diff --git a/yamf-core/src/main/java/nz/ac/wgtn/yamf/commons/OS.java b/yamf-core/src/main/java/nz/ac/wgtn/yamf/commons/OS.java index 99a461e..9262091 100644 --- a/yamf-core/src/main/java/nz/ac/wgtn/yamf/commons/OS.java +++ b/yamf-core/src/main/java/nz/ac/wgtn/yamf/commons/OS.java @@ -3,6 +3,8 @@ import org.zeroturnaround.exec.ProcessExecutor; import org.zeroturnaround.exec.ProcessResult; import java.io.*; +import java.nio.file.Path; +import java.nio.file.Paths; /** * Utilities to interact with the OS, in particular to run commands. @@ -25,5 +27,4 @@ public static ProcessResult exe(File workingDir, String... command) throws Excep .execute(); } - }