Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
opendir(3) OSS Library Calls Reference Manual
EXAMPLES
The following example shows how to open and search a directory for the entry name:
len = strlen(name);
dir_pointer = opendir(".");
for (dp = readdir(dir_pointer); dp != NULL;
dp = readdir(dir_pointer))
if (strlen(dp->d_name) == len && !strcmp(dp->d_name, name)) {
closedir(dir_pointer);
return FOUND;
}
closedir(dir_pointer);
return NOT_FOUND;
RETURN VALUES
Upon successful completion, the opendir( ) function returns a pointer to an object of type DIR.
Otherwise, null is returned and errno is set to indicate the error.
ERRORS
If any of the following conditions occurs, the opendir( ) function sets errno to the corresponding
value:
[EACCES] Search permission is denied for any component of the directory named by the
dir_name parameter, or read permission is denied for this name.
[EFSBAD] The fileset catalog for one of the filesets involved in the operation is corrupt.
[ELOOP] Too many symbolic links were encountered in translating the dir_name parame-
ter.
[ENAMETOOLONG]
One of the following is too long:
• The length of the pathname pointed to by the dir_name parameter
• A component of the pathname pointed to by the dir_name parameter
• The intermediate result of pathname resolution when a symbolic link is
part of the dir_name parameter
The pathconf( ) function can be called to obtain the applicable limits.
[ENOCRE] The function was called from a process that is not using the Common Run-Time
Environment (CRE).
[ENOENT] One of the following conditions exists:
• The dir_name parameter names a directory that does not exist.
• The dir_name parameter points to an empty string.
• The dir_name parameter points to a process name in /G that is not a sub-
type 30 process.
• The dir_name parameter specifies a directory on a remote HP NonStop
server node but communication with the remote node has been lost.
5−38 Hewlett-Packard Company 527187-017