Skip to content

Commit 66f4f55

Browse files
committed
auto merge of #14054 : luqmana/rust/at, r=alexcrichton
`/data/local/tmp` seems to be more common.
2 parents 47ecc2e + b55423a commit 66f4f55

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/libstd/os.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -529,9 +529,9 @@ pub fn homedir() -> Option<Path> {
529529
* Returns the path to a temporary directory.
530530
*
531531
* On Unix, returns the value of the 'TMPDIR' environment variable if it is
532-
* set and non-empty and '/tmp' otherwise.
533-
* On Android, there is no global temporary folder (it is usually allocated
534-
* per-app), hence returns '/data/tmp' which is commonly used.
532+
* set, otherwise for non-Android it returns '/tmp'. If Android, since there
533+
* is no global temporary folder (it is usually allocated per-app), we return
534+
* '/data/local/tmp'.
535535
*
536536
* On Windows, returns the value of, in order, the 'TMP', 'TEMP',
537537
* 'USERPROFILE' environment variable if any are set and not the empty
@@ -554,11 +554,13 @@ pub fn tmpdir() -> Path {
554554

555555
#[cfg(unix)]
556556
fn lookup() -> Path {
557-
if cfg!(target_os = "android") {
558-
Path::new("/data/tmp")
557+
let default = if cfg!(target_os = "android") {
558+
Path::new("/data/local/tmp")
559559
} else {
560-
getenv_nonempty("TMPDIR").unwrap_or(Path::new("/tmp"))
561-
}
560+
Path::new("/tmp")
561+
};
562+
563+
getenv_nonempty("TMPDIR").unwrap_or(default)
562564
}
563565

564566
#[cfg(windows)]

0 commit comments

Comments
 (0)