Table of Contents
The function opens the directory named by associates a
with it and returns a pointer to be used to identify the in subsequent
operations. The pointer is returned if cannot be accessed, or if it cannot
enough memory to hold the whole thing. The function returns a pointer
to the next directory entry. It returns upon reaching the end of the directory
or detecting an invalid operation. The function returns the current location
associated with the named The function sets the position of the next
operation on the The new position reverts to the one associated with
the when the operation was performed. Values returned by are good only
for the lifetime of the pointer, from which they are derived. If the directory
is closed and then reopened, the value may be invalidated due to undetected
directory compaction. It is safe to use a previous value immediately after
a call to and before any calls to The function resets the position
of the named to the beginning of the directory. The function closes the
named and frees the structure associated with the pointer, returning
0 on success. On failure, -1 is returned and the global variable is set
to indicate the error. The function returns the integer file descriptor
associated with the named see Sample code which searchs a directory
for entry ‘‘name’’ is: len = strlen(name)
; dirp = opendir("."); while ((dp
= readdir(dirp)) != NULL) if (dp->d_namlen == len && !strcmp(dp->d_name, name))
{
(void)closedir(dirp);
return FOUND;
}
(void)closedir(dirp); return NOT_FOUND;
The
and functions appeared in
Table of Contents