mdbx-tests: add osal_tempdir().

This commit is contained in:
Leo Yuriev 2018-03-19 20:40:10 +03:00
parent 0aa07cc09b
commit 838856f688
3 changed files with 18 additions and 0 deletions

View File

@ -272,3 +272,14 @@ void osal_udelay(unsigned us) {
} }
bool osal_istty(int fd) { return isatty(fd) == 1; } bool osal_istty(int fd) { return isatty(fd) == 1; }
std::string osal_tempdir(void) {
const char *tempdir = getenv("TEMPDIR");
if (!tempdir || *tempdir == '\0')
return (access("/dev/shm/", R_OK | W_OK | X_OK) == 0) ? "/dev/shm/" : "";
std::string dir(tempdir);
if (dir.at(dir.length() - 1) != '/')
dir.append("/");
return dir;
}

View File

@ -305,3 +305,9 @@ void osal_udelay(unsigned us) {
} }
bool osal_istty(int fd) { return _isatty(fd) != 0; } bool osal_istty(int fd) { return _isatty(fd) != 0; }
std::string osal_tempdir(void) {
char buf[MAX_PATH + 1];
DWORD len = GetTempPathA(sizeof(buf), buf);
return std::string(buf, len);
}

View File

@ -31,6 +31,7 @@ int osal_delay(unsigned seconds);
void osal_udelay(unsigned us); void osal_udelay(unsigned us);
void osal_yield(void); void osal_yield(void);
bool osal_istty(int fd); bool osal_istty(int fd);
std::string osal_tempdir(void);
#ifdef _MSC_VER #ifdef _MSC_VER
#ifndef STDIN_FILENO #ifndef STDIN_FILENO