system_rewinddir(3f) - [M_system:QUERY_FILE] call rewinddir(3c)
to rewind directory stream
(LICENSE:PD)
subroutine system_rewinddir(dir)
type(c_ptr),value :: dir
Return to pointer to the beginning of the list for a currently open
directory list.
DIR A C_pointer assumed to have been allocated by a call to
SYSTEM_OPENDIR(3f).
Sample program:
program demo_system_rewinddir
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)
!>>> 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
!>>> rewind directory stream
call system_rewinddir(dir)
enddo
!>>> close directory stream
call system_closedir(dir,ierr)
end program demo_system_rewinddir
John S. Urban
Public Domain
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(c_ptr), | value | :: | dir |
subroutine system_rewinddir(dir)
type(c_ptr),value :: dir
interface
subroutine c_rewinddir(c_dir) bind(c,name="rewinddir")
import c_char, c_int, c_ptr
type(c_ptr),value :: c_dir
end subroutine c_rewinddir
end interface
call c_rewinddir(dir)
end subroutine system_rewinddir