diff options
author | Tanzinul Islam <tanzinul.islam@gmail.com> | 2023-08-18 18:44:48 (GMT) |
---|---|---|
committer | Tanzinul Islam <t_17_7@hotmail.com> | 2023-08-18 18:44:48 (GMT) |
commit | 14d05f4708c97d1efc0db917dd32ef2f2013686a (patch) | |
tree | 6ef75e2568be06b716e0f20f5c18a1844f3d75a0 /googletest | |
parent | f42da0e4431a14260946323bff4d856f20973b2c (diff) | |
download | googletest-14d05f4708c97d1efc0db917dd32ef2f2013686a.zip googletest-14d05f4708c97d1efc0db917dd32ef2f2013686a.tar.gz googletest-14d05f4708c97d1efc0db917dd32ef2f2013686a.tar.bz2 |
Prefer $TMPDIR to /data/local/tmp on Android
Newer devices can have the latter location read-only. (I observed this with Termux on a non-rooted Pixel 6.)
Diffstat (limited to 'googletest')
-rw-r--r-- | googletest/src/gtest-port.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc index 2aaf2bc..589ace5 100644 --- a/googletest/src/gtest-port.cc +++ b/googletest/src/gtest-port.cc @@ -1064,7 +1064,13 @@ class CapturedStream { // The location /data/local/tmp is directly accessible from native code. // '/sdcard' and other variants cannot be relied on, as they are not // guaranteed to be mounted, or may have a delay in mounting. - name_template = "/data/local/tmp/"; + // + // However, prefer using the TMPDIR environment variable if set, as newer + // devices may have /data/local/tmp read-only. + if (auto tmpdir = ::getenv("TMPDIR")) + name_template.assign(tmpdir) += '/'; + else + name_template = "/data/local/tmp/"; #elif defined(GTEST_OS_IOS) char user_temp_dir[PATH_MAX + 1]; |