entry_name Function

private function entry_name(p) result(name)

The NUL-terminated name in the directory entry at p.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), intent(in) :: p

a struct dirent returned by c_readdir, with the layout known

Return Value character(len=:), allocatable


Called by

proc~~entry_name~~CalledByGraph proc~entry_name entry_name proc~list_directory list_directory proc~list_directory->proc~entry_name proc~collect_files collect_files proc~collect_files->proc~list_directory proc~directory_files directory_files proc~directory_files->proc~collect_files proc~run run proc~run->proc~directory_files

Source Code

function entry_name(p) result(name)
    !! The NUL-terminated name in the directory entry at `p`.
    type(c_ptr), intent(in) :: p        !! a `struct dirent` returned by `c_readdir`, with the layout known
    character(len=:), allocatable :: name
    character(kind=c_char), pointer :: raw(:)
    integer :: n, start

    start = NAME_OFFSETS(layout)
    call c_f_pointer(p, raw, [start + MAX_NAME])
    n = 0
    do while (n < MAX_NAME)
        if (raw(start + n + 1) == c_null_char) exit
        n = n + 1
    end do
    allocate (character(len=n) :: name)
    name = transfer(raw(start + 1:start + n), name)
end function entry_name