*** Welcome to piglix ***

Temporary file


Temporary files, or foo files (.TMP), are files created to temporarily contain information while a new file is being made. It may be created by computer programs for a variety of purposes; principally when a program cannot allocate enough memory for its tasks, when the program is working on data bigger than the architecture's address space, or as a primitive form of inter-process communication.

Modern operating systems employ virtual memory, however programs that use large amounts of data (e.g. video editing) may need to create temporary file(s).

Most operating systems offer primitives such as pipes, sockets or shared memory to pass data among programs, but often the simplest way (especially for programs that follow the Unix philosophy) is to write data into a temporary file and inform the receiving program of the location of the temporary file.

On POSIX systems, temporary files can be safely created with the mkstemp or tmpfile library functions. Some systems provide the former POSIX (now removed) mktemp(1) program. These files are typically located in the standard temporary directory, /tmp on Unix machines or %TEMP% (which is log-in specific) on Windows machines.

A temporary file created with tmpfile is deleted automatically when the program exits or the file is closed. To generate a temporary file name that will survive past the lifespan of the creating program, tmpnam (POSIX) or GetTempFileName(...) (Windows) can be used.


...
Wikipedia

...