ack/modules/src/system/tmpdir.c
carl b4df26e79d Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes.
+ Change function definitions to ANSI C style.
+ Initial support for CMake
+ Added support for sys_tmpdir for better portability.
2019-02-19 00:54:23 +08:00

27 lines
514 B
C

/* Copyright (c) 2019. See the file "Copyright" in
* the root directory for more information.
*
* Created on: 2019-02-09
*
*/
#include <stdlib.h>
char* sys_gettmpdir(void)
{
char* result = 0;
/* Check the UNIX temporary directory */
result = getenv("TMPDIR");
if (result != 0)
return result;
result = getenv("TMP");
if (result != 0)
return result;
/* DOS compatible systems */
result = getenv("TEMP");
if (result != 0)
return result;
/* Then try current directory */
return ".";
}