DOKK / manpages / debian 11 / atfs-dev / stUnRegisterFile.3.en
sttmpfiles(3) ShapeTools Toolkit Library sttmpfiles(3)

stTmpFile, stRegisterFile, stUnRegisterFile, stRmRegisteredFiles - temporary files handling

#include <config.h>
#include <sttk.h>

char* stTmpFile (char *path);

void stRegisterFile (char *fileName);

void stUnRegisterFile (char *fileName);

void stRmRegisteredFiles (void);

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.

stCatchSigs(3), stCleanup(3)

The maximum number of temporary files to be registered is 16.

Thu Jun 24 17:43:36 1993 sttk-1.7