Welcome to little lamb

Code » limb » master » tree

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

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

# NAME

open_tmp - open a new temporary file

# SYNOPSIS

    #include <limb/djbunix.h>

```pre hl
int open_tmp(char *<em>name</em>)
```

# DESCRIPTION

The `open_tmp`() 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.

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

# RETURN VALUE

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

# ERRORS

The `open_tmp`() 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_excl](3).