[libcxx-commits] [PATCH] D137131: [libc++][Android] temp dir is /data/local/tmp not /tmp

Ryan Prichard via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 31 15:56:08 PDT 2022


rprichard created this revision.
rprichard added reviewers: ldionne, danalbert.
Herald added subscribers: danielkiss, krytarowski.
Herald added a project: All.
rprichard requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137131

Files:
  libcxx/src/filesystem/operations.cpp
  libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp


Index: libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
+++ libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.temp_dir_path/temp_directory_path.pass.cpp
@@ -136,7 +136,7 @@
         std::error_code ec = GetTestEC();
         path ret = temp_directory_path(ec);
         TEST_CHECK(!ec);
-#ifndef _WIN32
+#if !defined(_WIN32) && !defined(__ANDROID__)
         // On Windows, the function falls back to the Windows folder.
         TEST_CHECK(ret == "/tmp");
 #endif
Index: libcxx/src/filesystem/operations.cpp
===================================================================
--- libcxx/src/filesystem/operations.cpp
+++ libcxx/src/filesystem/operations.cpp
@@ -1546,12 +1546,16 @@
 #else
   const char* env_paths[] = {"TMPDIR", "TMP", "TEMP", "TEMPDIR"};
   const char* ret = nullptr;
-
   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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137131.472170.patch
Type: text/x-patch
Size: 1267 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221031/ba7c37c4/attachment.bin>


More information about the libcxx-commits mailing list