From d3a98032343f4d73226f8db7c02c3d2643ba3712 Mon Sep 17 00:00:00 2001 From: Stephane Epardaud Date: Tue, 6 May 2014 12:58:51 +0200 Subject: [PATCH] FileUtil: added sameFile(File,File) for #4848 --- common/src/com/redhat/ceylon/common/FileUtil.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/common/src/com/redhat/ceylon/common/FileUtil.java b/common/src/com/redhat/ceylon/common/FileUtil.java index ef56aac9564..c0df5813ef9 100644 --- a/common/src/com/redhat/ceylon/common/FileUtil.java +++ b/common/src/com/redhat/ceylon/common/FileUtil.java @@ -311,4 +311,18 @@ public static String relativeFile(Iterable paths, String file){ return path; } + public static boolean sameFile(File a, File b) { + if(a == null) + return b == null; + if(b == null) + return false; + try { + String aPath = a.getCanonicalPath(); + String bPath = b.getCanonicalPath(); + return aPath.equals(bPath); + } catch (IOException e) { + return a.equals(b); + } + } + }