about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authoradridu59 <adri-from-59@hotmail.fr>2013-09-01 13:31:05 +0200
committeradridu59 <adri-from-59@hotmail.fr>2013-09-04 18:07:46 +0200
commit50d4714d859e6bc0bfecf8bdccb5c43fc917b9a2 (patch)
treeada6c222c9ab23961fe96faca0021cb330b373b0 /src/libstd
parent617850131b795312c4dd404ae7d853b54d883105 (diff)
downloadrust-50d4714d859e6bc0bfecf8bdccb5c43fc917b9a2.tar.gz
rust-50d4714d859e6bc0bfecf8bdccb5c43fc917b9a2.zip
libstd/os: set tmp dir to /data/tmp on Android
Android has no /tmp partition, return /data/tmp instead. Cf. #8511.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/os.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index 91408162788..0d77748b203 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -584,6 +584,8 @@ pub fn homedir() -> Option<Path> {
  *
  * On Unix, returns the value of the 'TMPDIR' environment variable if it is
  * set and non-empty and '/tmp' otherwise.
+ * On Android, there is no global temporary folder (it is usually allocated
+ * per-app), hence returns '/data/tmp' which is commonly used.
  *
  * On Windows, returns the value of, in order, the 'TMP', 'TEMP',
  * 'USERPROFILE' environment variable  if any are set and not the empty
@@ -606,7 +608,11 @@ pub fn tmpdir() -> Path {
 
     #[cfg(unix)]
     fn lookup() -> Path {
-        getenv_nonempty("TMPDIR").unwrap_or_default(Path("/tmp"))
+        if cfg!(target_os = "android") {
+            Path("/data/tmp")
+        } else {
+            getenv_nonempty("TMPDIR").unwrap_or_default(Path("/tmp"))
+        }
     }
 
     #[cfg(windows)]