Welcome to little lamb

Code » limb » release » tree

[release] / src / doc / djbunix.h / sa_realpathat.3.md

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

# NAME

sa_realpathat, sa_realpath - place canonicalized absolute pathname into a
stralloc

# SYNOPSIS

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

```pre hl
int sa_realpathat(stralloc *<em>sa</em>, int <em>fd</em>, const char *<em>path</em>)
int sa_realpath(stralloc *<em>sa</em>, const char *<em>path</em>)
```

# DESCRIPTION

The `sa_realpathat`() function expands all symbolic links and resolves
references to `.` and `..` in the NUL-terminated string pointed by `path` to
produce the corresponding canonicalized absolute pathname, added into the
stralloc pointed by `sa`.

If `path` specify a relative path, it is relative to the directory associated
with the file descriptor `fd`, which may be *AT_FDCWD* to use the current
working directory.

For more details, refer to [realpath](3).

The `sa_realpath`() macro is similar except when `path` specifies a relative
path, in which case it is relative to the current working directory.

# RETURN VALUE

On success these functions return 0. Otherwise they return -1 and set `errno` to
indicate the error.

# ERRORS

These functions may fail and set `errno` if :

: *ENOMEM*
:: Insufficient memory available to grow `sa`

They may may fail and set `errno` for any of the errors described for
[realpath](3).

The `sa_realpathat`() function may also fail and set `errno` for any of the
errors described for [open_read](3) or [fd_chdir](3).