/** * Invokes the closure for each subdirectory whose name (dir.name) matches the given nameFilter in the given directory * - calling the {@link DefaultGroovyMethods#isCase(java.lang.Object, java.lang.Object)} method to determine if a match occurs. This method can be used * with different kinds of filters like regular expressions, classes, ranges etc. * Only subdirectories are matched; regular files are ignored. * * @param self a Path (that happens to be a folder/directory) * @param nameFilter the nameFilter to perform on the name of the directory (using the {@link org.codehaus.groovy.runtime.DefaultGroovyMethods#isCase(Object, Object)} method) * @param closure the closure to invoke * @throws java.io.FileNotFoundException if the given directory does not exist * @throws IllegalArgumentException if the provided Path object does not represent a directory * @see #eachFileMatch(Path, groovy.io.FileType, Object, groovy.lang.Closure) * @since 2.3.0 */ public static void eachDirMatch(final Path self, final Object nameFilter, @ClosureParams(value = SimpleType.class, options = "java.nio.file.Path") final Closure closure) throws IOException { // throws FileNotFoundException, IllegalArgumentException { eachFileMatch(self, FileType.DIRECTORIES, nameFilter, closure); }
/** * Invokes the closure for each file whose name (file.name) matches the given nameFilter in the given directory * - calling the {@link org.codehaus.groovy.runtime.DefaultGroovyMethods#isCase(Object, Object)} method to determine if a match occurs. This method can be used * with different kinds of filters like regular expressions, classes, ranges etc. * Both regular files and subdirectories are matched. * * @param self a Path (that happens to be a folder/directory) * @param nameFilter the nameFilter to perform on the name of the file (using the {@link org.codehaus.groovy.runtime.DefaultGroovyMethods#isCase(Object, Object)} method) * @param closure the closure to invoke * @throws java.io.FileNotFoundException if the given directory does not exist * @throws IllegalArgumentException if the provided Path object does not represent a directory * @see #eachFileMatch(Path, groovy.io.FileType, Object, groovy.lang.Closure) * @since 2.3.0 */ public static void eachFileMatch(final Path self, final Object nameFilter, @ClosureParams(value = SimpleType.class, options = "java.nio.file.Path") final Closure closure) throws IOException { // throws FileNotFoundException, IllegalArgumentException { eachFileMatch(self, FileType.ANY, nameFilter, closure); }