diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-02-02 11:04:58 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-02-02 18:50:23 -0800 |
| commit | 9ece22ee00033cdf0b6b418c451112c92c8ad922 (patch) | |
| tree | bccd460a861e61f758d2d459cb9da02b1ad8792b /src/libstd/sys | |
| parent | fea07cfd3f29161451e3c3b35b17b340e5014b5c (diff) | |
| download | rust-9ece22ee00033cdf0b6b418c451112c92c8ad922.tar.gz rust-9ece22ee00033cdf0b6b418c451112c92c8ad922.zip | |
Test fixes and rebase conflicts
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/unix/os.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs index e93c3794a5a..b3f37962945 100644 --- a/src/libstd/sys/unix/os.rs +++ b/src/libstd/sys/unix/os.rs @@ -116,8 +116,7 @@ pub fn chdir(p: &Path) -> IoResult<()> { } pub struct SplitPaths<'a> { - iter: iter::Map<&'a [u8], Path, - slice::Split<'a, u8, fn(&u8) -> bool>, + iter: iter::Map<slice::Split<'a, u8, fn(&u8) -> bool>, fn(&'a [u8]) -> Path>, } @@ -450,7 +449,16 @@ pub fn temp_dir() -> Path { } pub fn home_dir() -> Option<Path> { - getenv("HOME".as_os_str()).or_else(|| unsafe { + return getenv("HOME".as_os_str()).or_else(|| unsafe { + fallback() + }).map(|os| { + Path::new(os.into_vec()) + }); + + #[cfg(target_os = "android")] + unsafe fn fallback() -> Option<OsString> { None } + #[cfg(not(target_os = "android"))] + unsafe fn fallback() -> Option<OsString> { let mut amt = match libc::sysconf(c::_SC_GETPW_R_SIZE_MAX) { n if n < 0 => 512 as usize, n => n as usize, @@ -470,7 +478,5 @@ pub fn home_dir() -> Option<Path> { let bytes = ffi::c_str_to_bytes(&ptr).to_vec(); return Some(OsStringExt::from_vec(bytes)) } - }).map(|os| { - Path::new(os.into_vec()) - }) + } } |
