The NUL-terminated name in the directory entry at p.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(c_ptr), | intent(in) | :: | p |
a |
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