public Globber filesOnly() { return filesOnly(true); }
public Globber dirsOnly() { return dirsOnly(true); }
static private void findSysvDaemons(Path unpackedDir, List<Daemon> daemons) throws IOException { Path dir = unpackedDir.resolve("share/init.d"); if (!Files.exists(dir)) { log.debug("{} dir not found (no sysv daemons?)", dir); return; } Globber.globber(dir, "*.init").filesOnly().stream().forEach((initFile) -> { log.debug("Detected sysv daemon {}", initFile); String name = initFile.getFileName().toString().replace(".init", ""); daemons.add(new Daemon(InitType.SYSV, name, null, null)); }); }
static public Globber globber(String rootWithGlob) { List<String> paths = BasicPaths.split(rootWithGlob); int globIndex = detectGlobIndex(paths); String root = null; // does it have a root? if (globIndex > 0) { root = BasicPaths.toString(paths, 0, globIndex, "/"); } Globber globber = new Globber(root); // does it have a glob? if (globIndex > -1) { String glob = BasicPaths.toString(paths, globIndex, paths.size(), "/"); globber.include(glob); } return globber; }
public Globber recursive() { return recursive(true); }
default public T exclude(PathMatcher matcher) { getGlobber().exclude(matcher); return (T)this; } }
public Stream<Path> stream() throws IOException { return scan().stream(); }
default public T include(PathMatcher matcher) { getGlobber().include(matcher); return (T)this; }
static private void findSystemdDaemons(Path unpackedDir, List<Daemon> daemons) throws IOException { Path dir = unpackedDir.resolve("share/systemd"); if (!Files.exists(dir)) { log.debug("{} dir not found (no systemd daemons?)", dir); return; } Globber.globber(dir, "*.service").filesOnly().stream().forEach((serviceFile) -> { log.debug("Detected systemd daemon {}", serviceFile); String name = serviceFile.getFileName().toString().replace(".service", ""); daemons.add(new Daemon(InitType.SYSTEMD, name, null, null)); }); }
static public Globber globber(String rootWithGlob) { List<String> paths = BasicPaths.split(rootWithGlob); int globIndex = detectGlobIndex(paths); String root = null; // does it have a root? if (globIndex > 0) { root = BasicPaths.toString(paths, 0, globIndex, "/"); } Globber globber = new Globber(root); // does it have a glob? if (globIndex > -1) { String glob = BasicPaths.toString(paths, globIndex, paths.size(), "/"); globber.include(glob); } return globber; }
public Globber recursive() { return recursive(true); }
default public T exclude(PathMatcher matcher) { getGlobber().exclude(matcher); return (T)this; } }
public Stream<Path> stream() throws IOException { return scan().stream(); }
default public T include(String glob) { getGlobber().include(glob); return (T)this; }
public Globber filesOnly() { return filesOnly(true); }
default public T recursive(boolean recursive) { getGlobber().recursive(recursive); return (T)this; }
default public T exclude(String glob) { getGlobber().exclude(glob); return (T)this; }
default public T paths(Globber globber) { ObjectHelper.requireNonNull(globber, "globber cannot be null"); try { return paths(globber.scan()); } catch (IOException e) { throw new BlazeException(e.getMessage(), e); } }