Skip to content

Commit 6a1cdcd

Browse files
author
Federico Fissore
committed
introduced FileUtils.getLinuxPathFrom: replaces backslashes with slashes
1 parent 67cb604 commit 6a1cdcd

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

app/src/processing/app/helpers/FileUtils.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
import java.io.FileOutputStream;
66
import java.io.IOException;
77
import java.util.Random;
8+
import java.util.regex.Pattern;
89

910
public class FileUtils {
1011

12+
private static final Pattern BACKSLASH = Pattern.compile("\\\\");
13+
1114
/**
1215
* Checks, whether the child directory is a subdirectory of the base directory.
13-
*
14-
* @param base
15-
* the base directory.
16-
* @param child
17-
* the suspected child directory.
16+
*
17+
* @param base the base directory.
18+
* @param child the suspected child directory.
1819
* @return true, if the child is a subdirectory of the base directory.
1920
*/
2021
public static boolean isSubDirectory(File base, File child) {
@@ -158,4 +159,8 @@ public static String relativePath(String origin, String target) {
158159

159160
return relative + target.substring(origin.length() + 1);
160161
}
162+
163+
public static String getLinuxPathFrom(File file) {
164+
return BACKSLASH.matcher(file.getAbsolutePath()).replaceAll("/");
165+
}
161166
}

0 commit comments

Comments
 (0)