NAME¶
stTmpFile, stRegisterFile, stUnRegisterFile, stRmRegisteredFiles - temporary
files handling
SYNOPSIS¶
#include <config.h>
#include <sttk.h>
char* stTmpFile (char *path);
void stRegisterFile (char *fileName);
void stUnRegisterFile (char *fileName);
void stRmRegisteredFiles (void);
DESCRIPTION¶
stTmpFile creates a unique filename for a temporary file, registers it
(see stRegisterFile below), and returns it. The return value resides in static
memory and will be overwritten on the next call of stTmpFile. The temporary
file is located in the
/tmp directory.
stRegisterFile adds the given
fileName to an internal static list
of file names. This list helps to keep track of the names of all temporary
files to be deleted until the end of the program execution. On abnormal
program termination (signal), the termination handler may call
stRmRegisteredFiles to delete all registered files. This avoids bogus
temporary files to survive abnormal program termination.
stUnRegisterFile removes
fileName from the internal list of file
names. It should be called when the corresponding file was removed due to the
regular control flow.
stRmRegisteredFiles removes all files named in the internal list set up
by stTmpFile and stRegisterFile and clears the list. Bogus entries in the list
(names without a correponding file) are ignored. Invoking
stCatchSigs(3)
causes stRmRegisteredFiles to be called on occurence of the signals SIGQUIT,
SIGFPE, SIGBUS, SIGSEGV, and SIGTERM.
stCleanup(3) also calls
stRmRegisteredFiles.
SEE ALSO¶
stCatchSigs(3),
stCleanup(3)
LIMITS¶
The maximum number of temporary files to be registered is 16.