@Test public void testIsParent() throws Exception { final File a = new File(path("one", "two", "three")); final File b = new File(path("one", "two")); final File c = new File(path("one", "..", "one", ".", "two", ".")); final File d = new File(path("two", "three")); assertTrue(isParent(b, a)); assertTrue(isParent(c, a)); assertFalse(isParent(d, a)); assertFalse(isParent(d, c)); assertFalse(isParent(a, b)); assertFalse(isParent(a, a)); }
public static boolean isParent(File a, File b) { try { final String aCanonical = a.getCanonicalPath(); final String bCanonical = b.getCanonicalPath(); return (!aCanonical.equals(bCanonical) && bCanonical.startsWith(aCanonical)); } catch (IOException e) { return false; } }
FileSupport { public static boolean isParent(File a, File b) { try { final String aCanonical = a.getCanonicalPath(); final String bCanonical = b.getCanonicalPath(); return (!aCanonical.equals(bCanonical) && bCanonical.startsWith(aCanonical)); } catch (IOException e) { return false; } } }
FileSupport { public static boolean isParent(File a, File b) { try { final String aCanonical = a.getCanonicalPath(); final String bCanonical = b.getCanonicalPath(); return (!aCanonical.equals(bCanonical) && bCanonical.startsWith(aCanonical)); } catch (IOException e) { return false; } } private  FileSupport(); }
FileSupport { public static boolean isParent(File a, File b) { try { final String aCanonical = a.getCanonicalPath(); final String bCanonical = b.getCanonicalPath(); return (!aCanonical.equals(bCanonical) && bCanonical.startsWith(aCanonical)); } catch (IOException e) { return false; } } private  FileSupport(); static File copy(File sourceLocation, File targetLocation); static File copy(File sourceFile, File targetFile, boolean overwrite); static File link(File sourceLocation, File targetLocation); static File link(final File sourceLocation, final File targetLocation, final boolean overwrite); static boolean supportsLinking(File sourceLocation, File targetLocation); static boolean deleteHierarchyIfEmpty(File limit, File start); static boolean isEqual(File a, File b); static boolean isParent(File a, File b); static boolean delete(File f); static boolean deleteQuietly(File f); static boolean deleteQuietly(File f, boolean recurse); static boolean delete(File f, boolean recurse); static boolean delete(File dir, int mode); static void setTempDirectory(File tmpDir); static File getTempDirectory(); static File getTempDirectory(String subdir); }
FileSupport { public static boolean isParent(File a, File b) { try { final String aCanonical = a.getCanonicalPath(); final String bCanonical = b.getCanonicalPath(); return (!aCanonical.equals(bCanonical) && bCanonical.startsWith(aCanonical)); } catch (IOException e) { return false; } } private  FileSupport(); static File copy(File sourceLocation, File targetLocation); static File copy(File sourceFile, File targetFile, boolean overwrite); static File link(File sourceLocation, File targetLocation); static File link(final File sourceLocation, final File targetLocation, final boolean overwrite); static boolean supportsLinking(File sourceLocation, File targetLocation); static boolean deleteHierarchyIfEmpty(File limit, File start); static boolean isEqual(File a, File b); static boolean isParent(File a, File b); static boolean delete(File f); static boolean deleteQuietly(File f); static boolean deleteQuietly(File f, boolean recurse); static boolean delete(File f, boolean recurse); static boolean delete(File dir, int mode); static void setTempDirectory(File tmpDir); static File getTempDirectory(); static File getTempDirectory(String subdir); static final int DELETE_FILES; static final int DELETE_ROOT; }