Welcome to little lamb

Code » limb » release » tree

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

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

# NAME

open_tmpat - open a new temporary file

# SYNOPSIS

    #include <limb/unix-transactional.h>

```pre hl
int open_tmpat(int <em>fd</em>, char *<em>name</em>)
```

# DESCRIPTION

The `open_tmpat`() function opens a new temporary file for writing, using a name
based on the template pointed by `name` - which must end with at least 6
characters `X` that will be replaced with random (printable) characters.

The memory pointed by `name` will be modified, replacing the trailing `X`
characters so that `name` contains the name of the file actually opened.

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

! NOTE:
! It is actually implemented as a macro to [mkfiletempat](3).

# RETURN VALUE

The `open_tmpat`() function returns the opened file descriptor on success.
Otherwise it returns -1 and sets `errno` to indicate the error.

# ERRORS

The `open_tmpat`() function may fail if :

: *EINVAL*
:: The template pointed by `name` does not end with at least 6 `X`.

It may also fail and set `errno` for the errors described for [open_exclat](3).