pxfisdir
- Date:
10-20-2011
NAME
PXFISDIR - Tests for directory file
SYNOPSIS
LOGICAL FUNCTION PXFISDIR(m)
INTEGER m
IF PXFISDIR(m) then
STANDARDS
IEEE Std 1003.9-1992 standard interface for FORTRAN 77
DESCRIPTION
The logical function PXFISDIR checks if a file is a directory file. The argument m should be supplied by the st_mode component of the stat structure used by the PXFSTAT(3F) routine.
All arguments must be of default kind unless documented otherwise. The default kind is KIND=4 for integer, real, complex, and logical arguments.
The following argument is available for this routine:
- m
An input integer variable containing the file mode.
If the file is a directory file, PXFISDIR returns a logical true, otherwise a logical false is returned.
EXAMPLES
In this example, the directory / is opened and read until a directory is found or the end of the directory is reached. If a directory is found, found a directory in / is displayed.
program pxftest
integer ierror,mode,ilen,EEND
integer idirid,jdirent,jstat
logical PXFISDIR, found
character*30 name, path
CALL PXFSTRUCTCREATE('dirent',jdirent,ierror)
CALL PXFSTRUCTCREATE('stat',jstat,ierror)
CALL PXFCONST('EEND',EEND,ierror)
path = '/'
CALL PXFOPENDIR(path,0,idirid,ierror)
CALL PXFCHDIR(path,0,ierror)
found = .FALSE.
do while (found .eqv. .FALSE.)
CALL PXFREADDIR(idirid,jdirent,ierror)
if (ierror .eq. EEND) then
exit
endif
CALL PXFSTRGET(jdirent,'d_name',name,ilen,ierror)
CALL PXFSTAT(name,0,jstat,ierror)
CALL PXFINTGET(jstat,'st_mode',mode,ierror)
if (PXFISDIR(mode)) then
found = .TRUE.
endif
enddo
if (found .eqv. .TRUE.) then
print *,'found a directory in /'
endif
end
SEE ALSO
PXFCONST(3F), PXFINTSET(3F), PXFSTAT(3F), PXFSTRUCTCREATE(3F)