directory_files Subroutine

private subroutine directory_files(cli, cache, dir, files, status)

The Fortran files under dir, selected with the [files] settings of its configuration and the command line.

Arguments

Type IntentOptional Attributes Name
type(cli_t), intent(in) :: cli

the parsed command line

type(config_cache_t), intent(inout) :: cache

configurations found so far

character(len=*), intent(in) :: dir

the directory, as given on the command line

type(string_t), intent(out), allocatable :: files(:)

paths of the files found

integer, intent(inout) :: status

exit status so far; set to EXIT_ERROR if the configuration cannot be read


Calls

proc~~directory_files~~CallsGraph proc~directory_files directory_files proc~absolute_path absolute_path proc~directory_files->proc~absolute_path proc~collect_files collect_files proc~directory_files->proc~collect_files proc~config_for config_for proc~directory_files->proc~config_for proc~default_exclude default_exclude proc~directory_files->proc~default_exclude proc~default_extensions default_extensions proc~directory_files->proc~default_extensions proc~current_directory current_directory proc~absolute_path->proc~current_directory proc~is_absolute is_absolute proc~absolute_path->proc~is_absolute proc~join_path join_path proc~absolute_path->proc~join_path fullmatch fullmatch proc~collect_files->fullmatch proc~child child proc~collect_files->proc~child proc~glob_to_regex glob_to_regex proc~collect_files->proc~glob_to_regex proc~list_directory list_directory proc~collect_files->proc~list_directory proc~sort_entries sort_entries proc~collect_files->proc~sort_entries regex regex proc~collect_files->regex proc~ends_with ends_with proc~config_for->proc~ends_with proc~find_config find_config proc~config_for->proc~find_config proc~load_config load_config proc~config_for->proc~load_config proc~child->proc~join_path interface~c_getcwd c_getcwd proc~current_directory->interface~c_getcwd proc~find_config->proc~join_path proc~find_config->proc~load_config proc~empty empty proc~find_config->proc~empty proc~parent_directory parent_directory proc~find_config->proc~parent_directory re_escape re_escape proc~glob_to_regex->re_escape proc~list_directory->proc~join_path interface~c_closedir c_closedir proc~list_directory->interface~c_closedir interface~c_opendir c_opendir proc~list_directory->interface~c_opendir interface~c_readdir c_readdir proc~list_directory->interface~c_readdir proc~byte_at byte_at proc~list_directory->proc~byte_at proc~c_string c_string proc~list_directory->proc~c_string proc~entry_name entry_name proc~list_directory->proc~entry_name proc~find_layout find_layout proc~list_directory->proc~find_layout proc~is_directory is_directory proc~list_directory->proc~is_directory get get proc~load_config->get get_keys get_keys proc~load_config->get_keys get_type get_type proc~load_config->get_type get_value get_value proc~load_config->get_value proc~load_config->proc~empty proc~to_s to_s proc~load_config->proc~to_s toml_load toml_load proc~load_config->toml_load proc~find_layout->interface~c_closedir proc~find_layout->interface~c_opendir proc~find_layout->interface~c_readdir proc~find_layout->proc~byte_at proc~find_layout->proc~c_string proc~is_directory->interface~c_closedir proc~is_directory->interface~c_opendir proc~is_directory->proc~c_string

Called by

proc~~directory_files~~CalledByGraph proc~directory_files directory_files proc~run run proc~run->proc~directory_files

Source Code

subroutine directory_files(cli, cache, dir, files, status)
    !! The Fortran files under `dir`, selected with the `[files]` settings of its configuration and
    !! the command line.
    type(cli_t), intent(in) :: cli                          !! the parsed command line
    type(config_cache_t), intent(inout) :: cache            !! configurations found so far
    character(len=*), intent(in) :: dir                     !! the directory, as given on the command line
    type(string_t), allocatable, intent(out) :: files(:)    !! paths of the files found
    integer, intent(inout) :: status                        !! exit status so far; set to `EXIT_ERROR` if the
                                                            !! configuration cannot be read
    type(config_t) :: cfg
    type(string_t), allocatable :: extensions(:), exclude(:)
    integer :: stat
    character(len=:), allocatable :: errmsg

    extensions = default_extensions()
    exclude = default_exclude()
    call config_for(cli, cache, absolute_path(dir), cfg, stat, errmsg)
    if (stat /= 0) then
        write (error_unit, '(a)') 'error: '//errmsg
        status = EXIT_ERROR
        allocate (files(0))
        return
    end if
    if (allocated(cfg%extensions)) extensions = cfg%extensions
    if (allocated(cfg%exclude)) exclude = cfg%exclude
    if (allocated(cli%extensions)) extensions = cli%extensions
    exclude = [exclude, cli%exclude]
    call collect_files(dir, extensions, exclude, files)
end subroutine directory_files