@Test public void testFilterSubpaths() { final Path p1 = Paths.get("./src/test/resources/foo/bar/empty.txt"); final Path p2 = Paths.get("./src/test/resources/foo/bar"); final Path p3 = Paths.get("./src/test/resources/foo"); final Path p4 = Paths.get("./src/test/resources/foo/empty"); final Set<Path> filter = new HashSet<Path>(); filter.add(p2); final Set<Path> to_be_filtered = new HashSet<Path>(); to_be_filtered.add(p1); to_be_filtered.add(p3); to_be_filtered.add(p4); final Set<Path> r1 = DirUtil.filterSubpaths(to_be_filtered, filter, true); assertEquals(1, r1.size()); final Set<Path> r2 = DirUtil.filterSubpaths(to_be_filtered, filter, false); assertEquals(2, r2.size()); }
public static Set<Path> filterSubpaths( Set<Path> _to_be_filtered, Set<Path> _filter, boolean _keep_subpaths) { final Set<Path> result = new HashSet<Path>(); for (Path p1 : _to_be_filtered) { boolean is_sub = false; for (Path p2 : _filter) { if (p1.startsWith(p2)) { is_sub = true; if (_keep_subpaths) { result.add(p1); break; } } } if (!_keep_subpaths && !is_sub) { result.add(p1); } } return result; }
DirUtil { public static Set<Path> filterSubpaths( Set<Path> _to_be_filtered, Set<Path> _filter, boolean _keep_subpaths) { final Set<Path> result = new HashSet<Path>(); for (Path p1 : _to_be_filtered) { boolean is_sub = false; for (Path p2 : _filter) { if (p1.startsWith(p2)) { is_sub = true; if (_keep_subpaths) { result.add(p1); break; } } } if (!_keep_subpaths && !is_sub) { result.add(p1); } } return result; } }
DirUtil { public static Set<Path> filterSubpaths( Set<Path> _to_be_filtered, Set<Path> _filter, boolean _keep_subpaths) { final Set<Path> result = new HashSet<Path>(); for (Path p1 : _to_be_filtered) { boolean is_sub = false; for (Path p2 : _filter) { if (p1.startsWith(p2)) { is_sub = true; if (_keep_subpaths) { result.add(p1); break; } } } if (!_keep_subpaths && !is_sub) { result.add(p1); } } return result; }  }
DirUtil { public static Set<Path> filterSubpaths( Set<Path> _to_be_filtered, Set<Path> _filter, boolean _keep_subpaths) { final Set<Path> result = new HashSet<Path>(); for (Path p1 : _to_be_filtered) { boolean is_sub = false; for (Path p2 : _filter) { if (p1.startsWith(p2)) { is_sub = true; if (_keep_subpaths) { result.add(p1); break; } } } if (!_keep_subpaths && !is_sub) { result.add(p1); } } return result; }  static final boolean containsFile(final File _dir, final String _filename); static File[] getAllFiles(final File _dir, final String[] _ignore); static File unzip(final File _zip, File _out_dir); static boolean isBelowDestinationPath(Path _destination_path, String _entry_name); static Set<Path> filterSubpaths(
      Set<Path> _to_be_filtered, Set<Path> _filter, boolean _keep_subpaths); static String getDigest(final File _dir, final String[] _ignore, DigestAlgorithm _alg); }
DirUtil { public static Set<Path> filterSubpaths( Set<Path> _to_be_filtered, Set<Path> _filter, boolean _keep_subpaths) { final Set<Path> result = new HashSet<Path>(); for (Path p1 : _to_be_filtered) { boolean is_sub = false; for (Path p2 : _filter) { if (p1.startsWith(p2)) { is_sub = true; if (_keep_subpaths) { result.add(p1); break; } } } if (!_keep_subpaths && !is_sub) { result.add(p1); } } return result; }  static final boolean containsFile(final File _dir, final String _filename); static File[] getAllFiles(final File _dir, final String[] _ignore); static File unzip(final File _zip, File _out_dir); static boolean isBelowDestinationPath(Path _destination_path, String _entry_name); static Set<Path> filterSubpaths(
      Set<Path> _to_be_filtered, Set<Path> _filter, boolean _keep_subpaths); static String getDigest(final File _dir, final String[] _ignore, DigestAlgorithm _alg);  }