diff options
author | Ryan Prichard <rprichard@google.com> | 2023-06-12 20:43:00 -0700 |
---|---|---|
committer | Ryan Prichard <rprichard@google.com> | 2023-06-12 20:43:00 -0700 |
commit | 1da06804e1a405e5399a1a19ae791a40f77dfbab (patch) | |
tree | 985098f46a08f42b30827245075dc77d33a80652 /libcxx/src/filesystem/operations.cpp | |
parent | 8f3fcbc6870deba0f4f52507faa93424a0939bc5 (diff) | |
download | llvm-1da06804e1a405e5399a1a19ae791a40f77dfbab.zip llvm-1da06804e1a405e5399a1a19ae791a40f77dfbab.tar.gz llvm-1da06804e1a405e5399a1a19ae791a40f77dfbab.tar.bz2 |
[libc++] Android temp dir is /data/local/tmp, enable Windows test
[libc++] Android temp dir is /data/local/tmp, enable Windows test
On Android, std::filesystem::temp_directory_path() should fall back to
/data/local/tmp when no environment variable is set. There is no /tmp
directory. Most apps can't access /data/local/tmp, but they do have a
"cache dir" (Context#getCacheDir()) that is usable for temporary files.
However, there is no obvious and reliable way for libc++ to query this
directory in contexts where it is available. The global fallback
/data/local/tmp is available for "adb shell", making it useful for test
suites.
On Windows, temp_directory_path falls back to the Windows directory
(e.g. "C:\Windows"), so call GetWindowsDirectoryW to do the test.
Reviewed By: ldionne, #libc, enh
Differential Revision: https://reviews.llvm.org/D137131
Diffstat (limited to 'libcxx/src/filesystem/operations.cpp')
-rw-r--r-- | libcxx/src/filesystem/operations.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp index fc14778..af31fe0 100644 --- a/libcxx/src/filesystem/operations.cpp +++ b/libcxx/src/filesystem/operations.cpp @@ -1550,8 +1550,13 @@ path __temp_directory_path(error_code* ec) { for (auto& ep : env_paths) if ((ret = getenv(ep))) break; - if (ret == nullptr) + if (ret == nullptr) { +#if defined(__ANDROID__) + ret = "/data/local/tmp"; +#else ret = "/tmp"; +#endif + } path p(ret); #endif |