def _filter_files(adir, filenames, filecnt, file_type, ffilter):
    """
    Filter files by file type(filter function) then returns matching
    files and cumulated count.
    """
    rfiles = ffilter(adir, filenames)
    filecnt += len(rfiles)
    return rfiles, filecnt