get_file_basename Function

public pure function get_file_basename(filename) result(basename)

Arguments

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

Return Value character(len=:), allocatable


Called by

proc~~get_file_basename~~CalledByGraph proc~get_file_basename get_file_basename proc~adjust_dso_name adjust_dso_name proc~adjust_dso_name->proc~get_file_basename proc~test_get_file_basename test_get_file_basename proc~test_get_file_basename->proc~get_file_basename

Source Code

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

      dot_index = find_extension_index(trim(filename))
      ! If the filename has no extension, return the filename
      if (dot_index > 0) then
         basename = trim(filename(1:dot_index-1))
      else
         basename = trim(filename)
      end if
   end function get_file_basename