Welcome to little lamb

Code » limb » release » tree

[release] / src / doc / direntry.h / opendirat.3.md

% limb manual
% opendirat(3)
% limb 0.1.0
% 2023-07-24

# NAME

opendirat - open a directory

# SYNOPSIS

    #include <fcntl.h> /* AT_FDCWD */
    #include <limb/direntry.h>

```pre hl
DIR *opendirat(int <em>fd</em>, const char *<em>name</em>)
```

# DESCRIPTION

The `opendirat`() function opens a directory stream corresponding to the
directory `name` and returns a pointer to the directory stream. The stream is
positioned at the first entry in the directory.

It is equivalent to the function [opendir](3) except when `name` specifies a
relative path, the directory to be opened is then determined relative to the
directory associated with the file descriptor `fd` instead of the current
working directory.

If passed the special value *AT_FDCWD* in the `fd` parameter, the current
working directory shall be used and the behavior shall be identical to a call to
[opendir](3).

# RETURN VALUE

Upon successful completion, the `opendirat` function returns a pointer to the
opened directory stream. Otherwise, it returns NULL and sets `errno` to indicate
the error.

# ERRORS

The `opendirat`() function may fail and set errno for any of the errors
specified for the functions [open](3) and [fdopendir](3).