Skip to content

Commit

Permalink
added utility to relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jensdietrich committed Jun 15, 2020
1 parent e0a66bc commit e9eb209
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
17 changes: 17 additions & 0 deletions yamf-core/src/main/java/nz/ac/wgtn/yamf/commons/Files.java
Original file line number Diff line number Diff line change
@@ -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();
}

}
3 changes: 2 additions & 1 deletion yamf-core/src/main/java/nz/ac/wgtn/yamf/commons/OS.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -25,5 +27,4 @@ public static ProcessResult exe(File workingDir, String... command) throws Excep
.execute();
}


}

0 comments on commit e9eb209

Please sign in to comment.