Welcome to little lamb

Code » limb » master » tree

[master] / src / doc / djbunix.h / fd_mkdirpat.3.md

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

# NAME

fd_mkdirpat, fd_mkdirp, mkdirpat, mkdirp - create a path of directories

# SYNOPSIS

    #include <limb/djbunix.h>

```pre hl
int fd_mkdirpat(int <em>fd</em>, const char *<em>name</em>, mode_t <em>mode</em>)
int fd_mkdirp(const char *<em>name</em>, mode_t <em>mode</em>)
int mkdirpat(int <em>fd</em>, const char *<em>name</em>, mode_t <em>mode</em>)
int mkdirp(const char *<em>name</em>, mode_t <em>mode</em>)
```

# DESCRIPTION

The `fd_mkdirpat`() function creates the path of directories `name`, i.e. it
attempts not only to create the last element of `name` but every single one.
This can be thinking thought of as equivalent to `mkdir --parent`.
The file permission bits of the new directory will be initialized from `mode`
for newly created directories (already existing ones aren't changed).

If `name` specifies 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.

A file descriptior to the last directory of the path in `name` is returned.

The `fd_mkdirp`() function is similar to `fd_mkdirpat`() except when `name`
specifies a relative path, in which case it is relative to the current working
directory.

The `mkdirpat`() function is similar to `fd_mkdirpat`() except that, on success,
it returns zero.

The `mkdirp`() function is similar to `fd_mkdirp`() except that, on success, it
returns zero.

# RETURN VALUE

The `fd_mkdirpat`() and `fd_mkdirp`() functions return a file descriptor to the
full directory specified in `name` on success. Otherwise, they return -1 and set
`errno` to indicate the error.

The `mkdirpat`() and `mkdirp`() functions return 0 on success. Otherwise, they
return -1 and set `errno` to indicate the error.

# ERRORS

These functions may fail and set errno for any of the errors specified for
[mkdirat](3) and [openat](3), save for *EEXIST*.