Find the offset of d_name from the . and .. entries of directory path.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | path |
a directory to list |
subroutine find_layout(path) !! Find the offset of `d_name` from the `.` and `..` entries of directory `path`. character(len=*), intent(in) :: path !! a directory to list type(c_ptr) :: dir, p logical :: dot(size(NAME_OFFSETS)), dotdot(size(NAME_OFFSETS)) integer :: k, status dir = c_opendir(c_string(path)) if (.not. c_associated(dir)) return dot = .false. dotdot = .false. do p = c_readdir(dir) if (.not. c_associated(p)) exit do k = 1, size(NAME_OFFSETS) if (byte_at(p, NAME_OFFSETS(k)) /= iachar('.')) cycle if (byte_at(p, NAME_OFFSETS(k) + 1) == 0) dot(k) = .true. if (byte_at(p, NAME_OFFSETS(k) + 1) == iachar('.') .and. byte_at(p, NAME_OFFSETS(k) + 2) == 0) & dotdot(k) = .true. end do end do status = c_closedir(dir) do k = 1, size(NAME_OFFSETS) if (dot(k) .and. dotdot(k)) then layout = k return end if end do end subroutine find_layout