system_realpath(3f) - [M_system:FILE_SYSTEM] call realpath(3c) to resolve a pathname (LICENSE:PD)
Synopsis
Description
Options
Return Value
Examples
function system_realpath(input) result(output)
character(len=*),intent(in) :: input character(len=:),allocatable :: output
system_realpath(3f) calls the C routine realpath(3c) to obtain the absolute pathname of given path
INPUT pathname to resolve
OUTPUT The absolute pathname of the given input pathname. The pathname shall contain no components that are dot or dot-dot, or are symbolic links. It is equal to the NULL character if an error occurred.
Sample program:
program demo_system_realpath use M_system, only : system_realpath, system_perror implicit none ! resolve each pathname given on command line character(len=:),allocatable :: pathi,patho integer :: i integer :: filename_length do i = 1, command_argument_count() ! get pathname from command line arguments call get_command_argument (i , length=filename_length) if(allocated(pathi))deallocate(pathi) allocate(character(len=filename_length) :: pathi) call get_command_argument (i , value=pathi) ! ! resolve each pathname patho=system_realpath(pathi) if(patho.ne.char(0))then write(*,*)trim(pathi),=>,trim(patho) else call system_perror(& & *system_realpath* error for pathname //trim(pathi)//:) write(*,*)trim(pathi),=>,trim(patho) endif deallocate(pathi) enddo ! if there were no pathnames given resolve the pathname "." if(i.eq.1)then patho=system_realpath(.) write(*,*).=>,trim(patho) endif end program demo_system_realpathExample usage:
demo_system_realpath .=>/home/urbanjs/V600cd /usr/share/man demo_system_realpath . .. NotThere .=>/usr/share/man ..=>/usr/share *system_realpath* error for pathname NotThere:: No such file or directory NotThere=>NotThere
Nemo Release 3.1 | system_realpath (3m_system) | March 07, 2025 |