chsvlib
chsv helper source code

◆ AllocateTempPath()

CHAR_TYPE* Chusov::String::AllocateTempPath ( )
noexcept

Allocates and returns an absolute path for a directory used for storing temporary files.

Template Parameters
CHAR_TYPEis a type of the allocated buffer. Currently the template is defined only for CHAR_TYPE=char and CHAR_TYPE=wchar_t resolving to AllocateTempPathA and AllocateTempPathW respectively.
Returns
On success the function returns a pointer to an allocated buffer initialized by a path to the directory for storing temporal files. The path is represented as a C string. Use FreeString or other free functions of the chsvmem.h header to free the returned buffer after its usage. If the function fails it returns NULL. Use GetLastChsvError to get extended error information.
Remarks
For Windows it is a value of the TEMP environment variable. For Linux and Sun it is a value of TMPDIR variable or an expansion of P_tmpdir macro or "/tmp" directory (the value is tried to be got in this sequence of system calls).
See also
AllocateUniqueTempFileName;
FreeString;
SecureFreeString;
AllocateString;
AllocateUniqueString;
AllocateAndFormatString.