From 6a1cdcdd035e3df6b9f209cf148d8b8c4bd35b83 Mon Sep 17 00:00:00 2001 From: Federico Fissore Date: Thu, 27 Jun 2013 17:35:34 +0200 Subject: [PATCH] introduced FileUtils.getLinuxPathFrom: replaces backslashes with slashes --- app/src/processing/app/helpers/FileUtils.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/processing/app/helpers/FileUtils.java b/app/src/processing/app/helpers/FileUtils.java index fc12616b0..e79da330d 100644 --- a/app/src/processing/app/helpers/FileUtils.java +++ b/app/src/processing/app/helpers/FileUtils.java @@ -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("/"); + } }