diff options
author | Xavier L'Heureux <xavier.lheureux@icloud.com> | 2019-07-16 15:02:54 -0400 |
---|---|---|
committer | Xavier L'Heureux <dev.xlheureux@gmail.com> | 2020-05-17 21:05:45 -0400 |
commit | e94c139a47055d3492d6ccccfce4acbcba9d7391 (patch) | |
tree | 7419cc1c1461cda63e4e2a735fd75e4a48677f81 /src/dir.rs | |
parent | 0259f9d51718b90118bbd1d792c88781d0aa98f7 (diff) | |
download | nix-e94c139a47055d3492d6ccccfce4acbcba9d7391.zip |
Remove more unsupported functions and make it possible to run tests
Diffstat (limited to 'src/dir.rs')
-rw-r--r-- | src/dir.rs | 23 |
1 files changed, 19 insertions, 4 deletions
@@ -1,17 +1,25 @@ +#[cfg(not(target_os = "redox"))] use {Error, NixPath, Result}; +#[cfg(not(target_os = "redox"))] use errno::Errno; +#[cfg(not(target_os = "redox"))] use fcntl::{self, OFlag}; use libc; -use std::os::unix::io::{IntoRawFd, RawFd}; #[cfg(not(target_os = "redox"))] -use std::os::unix::io::AsRawFd; -use std::{ffi, ptr}; +use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd}; +#[cfg(not(target_os = "redox"))] +use std::ptr; +use std::ffi; +#[cfg(not(target_os = "redox"))] use sys; #[cfg(target_os = "linux")] use libc::{dirent64 as dirent, readdir64_r as readdir_r}; -#[cfg(not(target_os = "linux"))] +#[cfg(target_os = "redox")] +use libc::dirent; + +#[cfg(not(any(target_os = "linux", target_os = "redox")))] use libc::{dirent, readdir_r}; /// An open directory. @@ -28,10 +36,12 @@ use libc::{dirent, readdir_r}; /// * returns entries' names as a `CStr` (no allocation or conversion beyond whatever libc /// does). #[derive(Clone, Debug, Eq, Hash, PartialEq)] +#[cfg(not(target_os = "redox"))] pub struct Dir( ptr::NonNull<libc::DIR> ); +#[cfg(not(target_os = "redox"))] impl Dir { /// Opens the given path as with `fcntl::open`. pub fn open<P: ?Sized + NixPath>(path: &P, oflag: OFlag, @@ -77,6 +87,7 @@ impl Dir { // call `readdir` simultaneously from multiple threads. // // `Dir` is safe to pass from one thread to another, as it's not reference-counted. +#[cfg(not(target_os = "redox"))] unsafe impl Send for Dir {} #[cfg(not(target_os = "redox"))] @@ -86,6 +97,7 @@ impl AsRawFd for Dir { } } +#[cfg(not(target_os = "redox"))] impl Drop for Dir { fn drop(&mut self) { unsafe { libc::closedir(self.0.as_ptr()) }; @@ -93,8 +105,10 @@ impl Drop for Dir { } #[derive(Debug, Eq, Hash, PartialEq)] +#[cfg(not(target_os = "redox"))] pub struct Iter<'d>(&'d mut Dir); +#[cfg(not(target_os = "redox"))] impl<'d> Iterator for Iter<'d> { type Item = Result<Entry>; @@ -121,6 +135,7 @@ impl<'d> Iterator for Iter<'d> { } } +#[cfg(not(target_os = "redox"))] impl<'d> Drop for Iter<'d> { fn drop(&mut self) { unsafe { libc::rewinddir((self.0).0.as_ptr()) } |