summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mdbx/src/libmdbx/test/osal-unix.cc
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Dbx_mdbx/src/libmdbx/test/osal-unix.cc')
-rw-r--r--plugins/Dbx_mdbx/src/libmdbx/test/osal-unix.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/plugins/Dbx_mdbx/src/libmdbx/test/osal-unix.cc b/plugins/Dbx_mdbx/src/libmdbx/test/osal-unix.cc
index 7625e0f419..8132e267ef 100644
--- a/plugins/Dbx_mdbx/src/libmdbx/test/osal-unix.cc
+++ b/plugins/Dbx_mdbx/src/libmdbx/test/osal-unix.cc
@@ -272,3 +272,22 @@ void osal_udelay(unsigned us) {
}
bool osal_istty(int fd) { return isatty(fd) == 1; }
+
+std::string osal_tempdir(void) {
+ 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 "";
+}