From 6d07b68f5e95debebe3983f8b2d9bfbc2afbe970 Mon Sep 17 00:00:00 2001 From: Nikita Baksalyar Date: Wed, 27 Jan 2016 05:46:28 +0300 Subject: Fix problems with f64 and DirEntry on Illumos --- src/libstd/sys/unix/fs.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/libstd/sys') diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs index 694aff6bbec..3e6242f6367 100644 --- a/src/libstd/sys/unix/fs.rs +++ b/src/libstd/sys/unix/fs.rs @@ -26,6 +26,8 @@ use sys_common::{AsInner, FromInner}; use vec::Vec; #[cfg(target_os = "sunos")] use core_collections::borrow::ToOwned; +#[cfg(target_os = "sunos")] +use boxed::Box; pub struct File(FileDesc); @@ -52,7 +54,7 @@ pub struct DirEntry { // store the name, b) its lifetime between readdir calls // is not guaranteed. #[cfg(target_os = "sunos")] - name: Arc> + name: Box<[u8]> } #[derive(Clone)] @@ -143,6 +145,10 @@ impl Iterator for ReadDir { fn next(&mut self) -> Option> { unsafe { loop { + // Although readdir_r(3) would be a correct function to use here because + // of the thread safety, on Illumos the readdir(3C) function is safe to use + // in threaded applications and it is generally preferred over the + // readdir_r(3C) function. let entry_ptr = libc::readdir(self.dirp.0); if entry_ptr.is_null() { return None @@ -153,8 +159,8 @@ impl Iterator for ReadDir { let ret = DirEntry { entry: *entry_ptr, - name: Arc::new(::slice::from_raw_parts(name as *const u8, - namelen as usize).to_owned()), + name: ::slice::from_raw_parts(name as *const u8, + namelen as usize).to_owned().into_boxed_slice(), root: self.root.clone() }; if ret.name_bytes() != b"." && ret.name_bytes() != b".." { -- cgit 1.4.1-3-g733a5