JAL-3244 ignore file path separator when comparing pdb file paths
[jalview.git] / src / jalview / util / Platform.java
index 22032b5..2c2c081 100644 (file)
@@ -20,7 +20,6 @@
  */
 package jalview.util;
 
-import java.awt.Toolkit;
 import java.awt.event.MouseEvent;
 
 /**
@@ -145,4 +144,27 @@ public class Platform
     }
     return e.isControlDown();
   }
+
+  /**
+   * 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);
+  }
 }