F90_UNIX_DIRENT

 

Index

NAME
USAGE
SYNOPSIS
PROCEDURE DESCRIPTION
SEE ALSO
BUGS
 

NAME

f90_unix_dirent - Module of Unix directory-reading operations  

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.  

SYNOPSIS

Procedures
CLOSEDIR, OPENDIR, READDIR, REWINDDIR
 

PROCEDURE DESCRIPTION

SUBROUTINE CLOSEDIR(DIRUNIT,ERRNO)
INTEGER,INTENT(IN) :: DIRUNIT
INTEGER,OPTIONAL,INTENT(OUT) :: ERRNO
Close 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,OPTIONAL,INTENT(OUT) :: ERRNO

Opens 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,INTENT(OUT) :: LENNAME
INTEGER,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. Note: The maximum file name length is available from SYSCONF; enquiry SC_NAME_MAX.

If there are no more directory entries, NAME is undefined 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,OPTIONAL,INTENT(OUT) :: ERRNO

Rewinds the directory stream so that the next call to READDIR on that stream will return the name of the first file in the directory.
 

SEE ALSO

f90_unix_errno(3), f95(1), nag_modules(3).  

BUGS

Please report any bugs found to "support@nag.co.uk", along with any suggestions for improvements.

© The Numerical Algorithms Group Ltd, Oxford UK. 2001