Merge branch 'test_paolo_JAL-1065' into Tcoffee_JAL-1065
[jalview.git] / src / jalview / util / Platform.java
index 392f1f9..ad9a9b7 100644 (file)
@@ -51,4 +51,23 @@ public class Platform
     // TODO: determine nominal limits for most platforms.\r
     return 2046; // this is the max length for a windows NT system.\r
   }\r
+\r
+  /**\r
+   * escape a string according to the local platform's escape character\r
+   * @param file\r
+   * @return escaped file\r
+   */\r
+  public static String escapeString(String file)\r
+  {\r
+    StringBuffer f=new StringBuffer();\r
+    int p=0,lastp=0;\r
+    while ((p=file.indexOf('\\',lastp))>-1)\r
+    {\r
+      f.append(file.subSequence(lastp,p));\r
+      f.append("\\\\");\r
+      lastp=p+1;\r
+    }\r
+    f.append(file.substring(lastp));\r
+    return f.toString();\r
+  }\r
 }\r