Merge "libbase: fix the way to find temp dir." am: b13d4a31a3 am: 8a5f594bc3

am: 03c1392aa3

Change-Id: I24fe4e6b8aaf8a26905704aecc4e7597cc4e1678
This commit is contained in:
Yabin Cui 2017-02-14 00:41:25 +00:00 committed by android-build-merger
commit e3f6a45f80

View file

@ -57,7 +57,13 @@ char* mkdtemp(char* template_name) {
static std::string GetSystemTempDir() {
#if defined(__ANDROID__)
return "/data/local/tmp";
const char* tmpdir = "/data/local/tmp";
if (access(tmpdir, R_OK | W_OK | X_OK) == 0) {
return tmpdir;
}
// Tests running in app context can't access /data/local/tmp,
// so try current directory if /data/local/tmp is not accessible.
return ".";
#elif defined(_WIN32)
char tmp_dir[MAX_PATH];
DWORD result = GetTempPathA(sizeof(tmp_dir), tmp_dir);