From 0959f1b070fb346305545057ba431d03e8dd6369 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 ceylon/ceylon-runtime#53 --- src/com/redhat/ceylon/common/FileUtil.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/com/redhat/ceylon/common/FileUtil.java b/src/com/redhat/ceylon/common/FileUtil.java index ef56aac..c0df581 100644 --- a/src/com/redhat/ceylon/common/FileUtil.java +++ b/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); + } + } + }