Manual Reference Pages  - system_readdir (3m_system)

NAME

system_readdir(3f) - [M_system:QUERY_FILE] read a directory using readdir(3c) (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Returns
Examples
Author
License

SYNOPSIS

subroutine system_readdir(dir,filename,ierr)

     type(c_ptr),value                         :: dir
     character(len=:),intent(out),allocatable  :: filename
     integer,intent(out)                       :: ierr

DESCRIPTION

system_readdir(3f) returns the name of the directory entry at the current position in the directory stream specified by the argument DIR, and positions the directory stream at the next entry. It returns a null name upon reaching the end of the directory stream.

OPTIONS

DIR A pointer to the directory opened by system_opendir(3f).

RETURNS

FILENAME
  the name of the directory entry at the current position in the directory stream specified by the argument DIR, and positions the directory stream at the next entry.

The readdir() function does not return directory entries containing empty names. If entries for dot or dot-dot exist, one entry is returned for dot and one entry is returned for dot-dot.

The entry is marked for update of the last data access timestamp each time it is read.

reaching the end of the directory stream, the name is a blank name.

IERR If IERR is set to non-zero on return, an error occurred.

EXAMPLES

Sample program:

   program demo_system_readdir
   use M_system, only : system_opendir,system_readdir
   use M_system, only : system_rewinddir,system_closedir
   use iso_c_binding
   implicit none

type(c_ptr) :: dir character(len=:),allocatable :: filename integer :: i, ierr !--- open directory stream to read from call system_opendir(’.’,dir,ierr) if(ierr.eq.0)then !--- read directory stream twice do i=1,2 write(*,’(a,i0)’)’PASS ’,i do call system_readdir(dir,filename,ierr) if(filename.eq.’ ’)exit write(*,*)filename enddo call system_rewinddir(dir) enddo endif !--- close directory stream call system_closedir(dir,ierr)

end program demo_system_readdir

AUTHOR

John S. Urban

LICENSE

Public Domain


Nemo Release 3.1 system_readdir (3m_system) March 07, 2025
Generated by manServer 1.08 from 5e7d0ef8-b8dd-4304-9c96-acd244eec5f8 using man macros.