ffmt_walk Module

Finding the Fortran files under a directory.

Files are selected by extension. Entries are excluded by glob patterns: * and ? match within a path component, ** across components, and [abc] / [!abc] match one character. A pattern without a / is matched against an entry's name, one with a / against its path relative to the directory being searched. Links to directories are not followed.


Uses

  • module~~ffmt_walk~~UsesGraph module~ffmt_walk ffmt_walk fregex fregex module~ffmt_walk->fregex module~ffmt_fs ffmt_fs module~ffmt_walk->module~ffmt_fs module~ffmt_strings ffmt_strings module~ffmt_walk->module~ffmt_strings iso_c_binding iso_c_binding module~ffmt_fs->iso_c_binding

Used by

  • module~~ffmt_walk~~UsedByGraph module~ffmt_walk ffmt_walk module~ffmt_cli ffmt_cli module~ffmt_cli->module~ffmt_walk

Variables

Type Visibility Attributes Name Initial
integer, private, parameter :: MAX_DEPTH = 100

Functions

private pure function child(dir, name) result(path)

dir/name, or just name in the current directory.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: dir

the directory, and the name of an entry in it

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

the directory, and the name of an entry in it

Return Value character(len=:), allocatable

public function default_exclude() result(list)

Hidden files and directories, and fpm's build directory.

Arguments

None

Return Value type(string_t), allocatable, (:)

public function default_extensions() result(list)

Extensions of free-form Fortran files.

Arguments

None

Return Value type(string_t), allocatable, (:)

public function glob_to_regex(glob) result(re)

A regular expression (for a full match) equivalent to the glob pattern glob.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: glob

the glob pattern

Return Value character(len=:), allocatable


Subroutines

public subroutine collect_files(root, extensions, exclude, files)

The files under directory root with one of the extensions (without the dot) that are not excluded, sorted by path within each directory.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: root

the directory to search

type(string_t), intent(in) :: extensions(:)

extensions of the files to collect, without the dot

type(string_t), intent(in) :: exclude(:)

glob patterns of the files and directories to skip

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

paths of the files, root joined with their relative paths (just those if root is .)

private subroutine sort_entries(entries)

Sort by name (insertion sort: directories are small).

Arguments

Type IntentOptional Attributes Name
type(dir_entry_t), intent(inout) :: entries(:)

a directory listing