mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 00:24:13 +08:00
mdbx-tests: refine temp-dir for unix.
This commit is contained in:
parent
52283d8c44
commit
5872174db6
@ -274,12 +274,20 @@ 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;
|
||||
const char *tempdir = getenv("TMPDIR");
|
||||
if (!tempdir)
|
||||
tempdir = getenv("TMP");
|
||||
if (!tempdir)
|
||||
tempdir = getenv("TEMPDIR");
|
||||
if (!tempdir)
|
||||
tempdir = getenv("TEMP");
|
||||
if (tempdir) {
|
||||
std::string dir(tempdir);
|
||||
if (!dir.empty() && dir.at(dir.length() - 1) != '/')
|
||||
dir.append("/");
|
||||
return dir;
|
||||
}
|
||||
if (access("/dev/shm/", R_OK | W_OK | X_OK) == 0)
|
||||
return "/dev/shm/";
|
||||
return "";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user