---
name: "tmp_name"
section: "3abz"
platform: "linux"
package: "libabz0-dev"
version: "0.5.1"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/tmp_name"
---

# tmp\_name(3abz)

create names for temporary files safely.

## NAME

tmp\_open, tmp\_name, tmp\_close - create names for temporary files safely.

## LIBRARIES

Abz Library (-labz), Debug Library (-ldebug)

## SYNOPSIS

```
#include <abz/tmp.h>

int tmp_open(const char *tmpdir, const char *progname);
char *tmp_name();
void tmp_close();
```

## DESCRIPTION

The **tmp\_open()** function creates a temporary directory (only accessible by the user of the process in question) for use by the **tmp\_name()** function. You have to specify a temporary directory *tmpdir* and a program name *progname*. These strings are used to create a directory of the form *\<tmpdir\>/\<progname\>hash*.

The **tmp\_name()** function creates a name for a temporary file which is safe to use.

The **tmp\_close()** function removes the directory created by **tmp\_open()**. It is the responsibility of the programmer to ensure that the directory is empty (i.e. all the files/directories created with names generated by **tmp\_name()** were removed) by the time this function is called.

## RETURN VALUES

The **tmp\_open()** function returns 0 if successful, -1 if not.

The **tmp\_name()** function returns a name if successful, NULL if not.

Check *errno* to see what error occurred.

## NOTES

None of the libabz routines are thread-safe. I'm not planning to change this either! For more information, please see http://threading.2038bug.com/

## AUTHOR

Written by Abraham vd Merwe \<abz@blio.com\>
