get_file_extension Function

public pure function get_file_extension(filename) result(extension)

Arguments

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

Return Value character(len=:), allocatable


Called by

proc~~get_file_extension~~CalledByGraph proc~get_file_extension get_file_extension proc~is_supported_dso_name is_supported_dso_name proc~is_supported_dso_name->proc~get_file_extension proc~is_valid_dso_name is_valid_dso_name proc~is_valid_dso_name->proc~get_file_extension proc~test_get_file_extension test_get_file_extension proc~test_get_file_extension->proc~get_file_extension

Source Code

   pure function get_file_extension(filename) result(extension)
      ! Function that returns the extension of a string filename
      ! where filename is "basename.extension"
      character(len=*), intent(in) :: filename
      character(len=:), allocatable :: extension
      integer :: dot_index

      dot_index = find_extension_index(trim(filename))
      ! If the filename has no extension, return blank string
      if (dot_index > 0) then
         extension = trim(filename(dot_index:))
      else
         extension = ''
      endif
   end function get_file_extension