f90_unix_dirent: Unix Directory-reading Operations Module
Table of Contents
1 Name
f90_unix_dirent
— Module of Unix directory-reading operations
2 Usage
USE F90_UNIX_DIRENT
This module contains part of a Fortran API to functions detailed in ISO/IEC 9945-1:1990 Portable Operating System Interface (POSIX) - Part 1: System Application Program Interface (API) [C Language].
The functions in this module are from Section 5.1.2: Directory Operations
Error handling is described in F90_UNIX_ERRNO
.
Note that for procedures with an optional ERRNO
argument, if an error
occurs and ERRNO
is not present, the program will be terminated.
All the procedures in this module are specific and not generic.
3 Synopsis
- Generic Procedures
CLOSEDIR
,OPENDIR
,READDIR
,REWINDDIR
.
4 Procedure Description
In the description of each procedure, an argument whose KIND
is denoted
by ‘*’ can accept any kind of that type.
Other KIND
indications use the named parameters from the F90_KIND
or F90_UNIX_ERRNO
modules; these named parameters are not, however,
exported from F90_UNIX_DIRENT
.
SUBROUTINE CLOSEDIR(DIRUNIT,ERRNO) INTEGER(*),INTENT(IN) :: DIRUNIT INTEGER(error_kind),OPTIONAL,INTENT(OUT) :: ERRNOClose a directory stream that was opened by
OPENDIR
.
If DIRUNIT
does not refer to an open directory stream,
error EBADF
(see F90_UNIX_ERRNO
) is raised.
SUBROUTINE OPENDIR(DIRNAME,DIRUNIT,ERRNO) CHARACTER(*),INTENT(IN) :: DIRNAME INTEGER(*),INTENT(OUT) :: DIRUNIT INTEGER(error_kind),OPTIONAL,INTENT(OUT) :: ERRNOOpens a directory stream, returning a handle to it in
DIRUNIT
.
Possible errors include EACCES
, ENAMETOOLONG
, ENOENT
,
ENOTDIR
, EMFILE
and ENFILE
(see F90_UNIX_ERRNO
).
SUBROUTINE READDIR(DIRUNIT,NAME,LENNAME,ERRNO) INTEGER(*),INTENT(IN) :: DIRUNIT CHARACTER(*),INTENT(OUT) :: NAME INTEGER(int32 or int64),INTENT(OUT) :: LENNAME INTEGER(error_kind),OPTIONAL,INTENT(OUT) :: ERRNO
Reads the first/next directory entry.
The name of the file is placed into NAME
, blank-padded or truncated as
appropriate if the length of the file name differs from LEN(NAME)
.
The length of the file name is placed in LENNAME
.
If there are no more directory entries, NAME
is unchanged and
LENNAME
is negative.
If DIRUNIT
is not a directory stream handle produced by OPENDIR
,
or has been closed by CLOSEDIR
, error EBADF
(see
F90_UNIX_ERRNO
) is raised.
SUBROUTINE REWINDDIR(DIRUNIT,ERRNO) INTEGER(*),INTENT(IN) :: DIRUNIT INTEGER(error_kind),OPTIONAL,INTENT(OUT) :: ERRNORewinds the directory stream so that the next call to
READDIR
on that
stream will return the name of the first file in the directory.
5 See Also
f90_unix_env(3), f90_unix_errno(3), intro(3), nag_modules(3), nagfor(1).
6 Bugs
Please report any bugs found to ‘support@nag.co.uk’ or ‘support@nag.com’, along with any suggestions for improvements.