public FileVisitResult postVisitDirectory()

in src/main/java/org/apache/maven/plugins/clean/Cleaner.java [319:344]


    public FileVisitResult postVisitDirectory(Path dir, IOException failure) throws IOException {
        boolean canDelete = !nonEmptyDirectoryLevels.get(currentDepth--); // False if the directory is not empty.
        if (failure != null) {
            if (logger.isWarnEnabled()) {
                logger.warn("Error in directory " + dir, failure);
            }
            failureCount++;
            canDelete = false;
        } else {
            canDelete &= (currentDepth != 0 || !isBaseDirectoryExcluded);
            if (canDelete && selector != null) {
                canDelete = selector.matches(dir);
            }
        }
        if (canDelete) {
            if (tryDelete(dir) && listDeletedFiles) {
                logDelete(dir, null);
            }
        } else {
            nonEmptyDirectoryLevels.set(currentDepth); // Remember that the parent of `dir` is not empty.
        }
        if (failure != null && failOnError) {
            throw failure;
        }
        return FileVisitResult.CONTINUE;
    }