tmp_name(3abz)

tmp_name3abz

Create names for temporary files safely.

Usage

#include <abz/tmp.h>

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

Libraries

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

Overview

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 <[email protected]>

From libabz0-dev 0.5.1 in Debian 3.1 (Sarge). Parsed by carta from the page's man source.