introduced FileUtils.getLinuxPathFrom: replaces backslashes with slashes

This commit is contained in:
Federico Fissore 2013-06-27 17:35:34 +02:00
parent 67cb6047de
commit 6a1cdcdd03
1 changed files with 10 additions and 5 deletions

View File

@ -5,16 +5,17 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Random;
import java.util.regex.Pattern;
public class FileUtils {
private static final Pattern BACKSLASH = Pattern.compile("\\\\");
/**
* Checks, whether the child directory is a subdirectory of the base directory.
*
* @param base
* the base directory.
* @param child
* the suspected child directory.
*
* @param base the base directory.
* @param child the suspected child directory.
* @return true, if the child is a subdirectory of the base directory.
*/
public static boolean isSubDirectory(File base, File child) {
@ -158,4 +159,8 @@ public class FileUtils {
return relative + target.substring(origin.length() + 1);
}
public static String getLinuxPathFrom(File file) {
return BACKSLASH.matcher(file.getAbsolutePath()).replaceAll("/");
}
}