chsvlib
chsv helper source code

◆ AllocateUniqueTempFileName()

CHAR_TYPE* Chusov::String::AllocateUniqueTempFileName ( const CHAR_TYPE *  lpszExtension)
noexcept

Allocates and returns an absolute a unique file name based on UUID and that is to be located in the system temporary directory.

Template Parameters
CHAR_TYPEis a type of the allocated string. Currently the template is defined only for CHAR_TYPE=char and CHAR_TYPE=wchar_t resolving to AllocateUniqueTempFileNameA and AllocateUniqueTempFileNameW respectively.
Parameters
[in]lpszExtensionis an optional string specifying an extension for the file name. If the parameter is NULL the file name is generated without extension.
Returns
On success the function returns an absolute path to a unique file that is to be located in the temporary directory returned by the AllocateTempPath function. The file itself is not created, but only its name, which is based on UUID is returned. When the returned value is no longer needed, free the returned buffer using the FreeString, SecureFreeString or any other free function of the chsvmem.h header. If the function fails it returns NULL. Use GetLastChsvError to get extended error information.
Remarks
The string is returned in format "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.lpszExtension" plus the terminating zero as the last character.
The function does not try to create file or to check validity of its name.
See also
AllocateTempPath;
FreeString;
AllocateString;
AllocateUniqueString;
AllocateAndFormatString.