mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-30 02:14:12 +08:00
mdbx-tests: add osal_tempdir().
This commit is contained in:
parent
0aa07cc09b
commit
838856f688
@ -272,3 +272,14 @@ void osal_udelay(unsigned us) {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -305,3 +305,9 @@ void osal_udelay(unsigned us) {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ int osal_delay(unsigned seconds);
|
||||
void osal_udelay(unsigned us);
|
||||
void osal_yield(void);
|
||||
bool osal_istty(int fd);
|
||||
std::string osal_tempdir(void);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifndef STDIN_FILENO
|
||||
|
Loading…
x
Reference in New Issue
Block a user