template <class character>
unsigned get_temporary_file_name(const character* path_name,
                                 const character* prefix,
                                 unsigned suffix,
                                 character* temporary)

This function obtains a temporary file name.


const character* path_name

A pointer to a string holding the directory for the filename. This string may consist only of ANSI characters. A period (.) may be specified to indicate the current directory. The function get_temporary_path may be used to obtain a temporary path for the file. This parameter may not be null.

const character* prefix

A pointer to a string, the first three characters of which are used as the index of the temporary file name. Only ANSI characters may be used.

unsigned suffix

A value that is converted to a hexadecimal string which is used when creating the temporary filename.

If a nonzero value is specified, the resultant hexadecimal string is combined with prefix to form the temporary filename. In this case, a temporary file is not created and no test for uniqueness is applied.

If zero is specified, the resultant hexadecimal string derived from the current system time. In this case, the function uses different values until it finds a unique filename, and then it creates the file in the directory given by path parameter.

character* temporary

A pointer to a buffer that receives the temporary file name. The buffer should be at least path_length::maximum characters in size.



The value returned is the unique numeric value used to generate the temporary file name. This is equal to unique, when that value is non-zero on input. If an error occurs, zero is returned.


This function creates name suitable for a temporary file which has the following form:



path The path specified by the first parameter.
pre The first three letters of the prefix string.
uuuu The hexadecimal value of Suffix.

Files created with names generated by this function are not automatically deleted.