X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FPlatform.java;fp=src%2Fjalview%2Futil%2FPlatform.java;h=728110ee1463e0a95fe9708e08ad49655ec482da;hb=25e36b8f366dab01f838d8175e59e9148628eb68;hp=c511ce3f024e19a0017b8c8e3e4e1f98e2c965b9;hpb=c28e0a185e32f7b8b2a4e649415355f3a034228a;p=jalview.git diff --git a/src/jalview/util/Platform.java b/src/jalview/util/Platform.java index c511ce3..728110e 100644 --- a/src/jalview/util/Platform.java +++ b/src/jalview/util/Platform.java @@ -158,23 +158,17 @@ public class Platform } /** - * escape a string according to the local platform's escape character + * An earlier version of escapeString()? Looks fine to me -- BH * - * @param file - * @return escaped file + * Answers the input with every backslash replaced with a double backslash (an + * 'escaped' single backslash) + * + * @param s + * @return */ - public static String escapeString(String file) + public static String escapeBackslashes(String s) { - StringBuffer f = new StringBuffer(); - int p = 0, lastp = 0; - while ((p = file.indexOf('\\', lastp)) > -1) - { - f.append(file.subSequence(lastp, p)); - f.append("\\\\"); - lastp = p + 1; - } - f.append(file.substring(lastp)); - return f.toString(); + return s == null ? null : s.replace("\\", "\\\\"); } /** @@ -714,6 +708,29 @@ public class Platform } + /** + * A (case sensitive) file path comparator that ignores the difference between + * / and \ + * + * @param path1 + * @param path2 + * @return + */ + public static boolean pathEquals(String path1, String path2) + { + if (path1 == null) + { + return path2 == null; + } + if (path2 == null) + { + return false; + } + String p1 = path1.replace('\\', '/'); + String p2 = path2.replace('\\', '/'); + return p1.equals(p2); + } + public static URL getDocumentBase() { return (isJS ? jsutil.getDocumentBase() : null);