Skip to content

Commit

Permalink
Remove special casing for Redox (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed May 21, 2020
1 parent 859f4de commit 2a0a7cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
11 changes: 3 additions & 8 deletions src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ impl<'a> EntryFields<'a> {
::std::os::windows::fs::symlink_file(src, dst)
}

#[cfg(any(unix, target_os = "redox"))]
#[cfg(unix)]
fn symlink(src: &Path, dst: &Path) -> io::Result<()> {
::std::os::unix::fs::symlink(src, dst)
}
Expand Down Expand Up @@ -623,7 +623,7 @@ impl<'a> EntryFields<'a> {
})
}

#[cfg(any(unix, target_os = "redox"))]
#[cfg(unix)]
fn _set_perms(
dst: &Path,
f: Option<&mut std::fs::File>,
Expand Down Expand Up @@ -717,12 +717,7 @@ impl<'a> EntryFields<'a> {
}
// Windows does not completely support posix xattrs
// https://en.wikipedia.org/wiki/Extended_file_attributes#Windows_NT
#[cfg(any(
windows,
target_os = "redox",
not(feature = "xattr"),
target_arch = "wasm32"
))]
#[cfg(any(windows, not(feature = "xattr"), target_arch = "wasm32"))]
fn set_xattrs(_: &mut EntryFields, _: &Path) -> io::Result<()> {
Ok(())
}
Expand Down
22 changes: 5 additions & 17 deletions src/header.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[cfg(any(unix, target_os = "redox"))]
#[cfg(unix)]
use std::os::unix::prelude::*;
#[cfg(windows)]
use std::os::windows::prelude::*;
Expand Down Expand Up @@ -719,7 +719,7 @@ impl Header {
unimplemented!();
}

#[cfg(any(unix, target_os = "redox"))]
#[cfg(unix)]
fn fill_platform_from(&mut self, meta: &fs::Metadata, mode: HeaderMode) {
match mode {
HeaderMode::Complete => {
Expand Down Expand Up @@ -756,7 +756,6 @@ impl Header {
// TODO: need to bind more file types
self.set_entry_type(entry_type(meta.mode()));

#[cfg(not(target_os = "redox"))]
fn entry_type(mode: u32) -> EntryType {
match mode as libc::mode_t & libc::S_IFMT {
libc::S_IFREG => EntryType::file(),
Expand All @@ -768,17 +767,6 @@ impl Header {
_ => EntryType::new(b' '),
}
}

#[cfg(target_os = "redox")]
fn entry_type(mode: u32) -> EntryType {
use syscall;
match mode as u16 & syscall::MODE_TYPE {
syscall::MODE_FILE => EntryType::file(),
syscall::MODE_SYMLINK => EntryType::symlink(),
syscall::MODE_DIR => EntryType::dir(),
_ => EntryType::new(b' '),
}
}
}

#[cfg(windows)]
Expand Down Expand Up @@ -1542,7 +1530,7 @@ fn ends_with_slash(p: &Path) -> bool {
last == Some(b'/' as u16) || last == Some(b'\\' as u16)
}

#[cfg(any(unix, target_os = "redox"))]
#[cfg(unix)]
fn ends_with_slash(p: &Path) -> bool {
p.as_os_str().as_bytes().ends_with(&[b'/'])
}
Expand All @@ -1569,7 +1557,7 @@ pub fn path2bytes(p: &Path) -> io::Result<Cow<[u8]>> {
})
}

#[cfg(any(unix, target_os = "redox"))]
#[cfg(unix)]
/// On unix this will never fail
pub fn path2bytes(p: &Path) -> io::Result<Cow<[u8]>> {
Ok(p.as_os_str().as_bytes()).map(Cow::Borrowed)
Expand Down Expand Up @@ -1598,7 +1586,7 @@ pub fn bytes2path(bytes: Cow<[u8]>) -> io::Result<Cow<Path>> {
}
}

#[cfg(any(unix, target_os = "redox"))]
#[cfg(unix)]
/// On unix this operation can never fail.
pub fn bytes2path(bytes: Cow<[u8]>) -> io::Result<Cow<Path>> {
use std::ffi::{OsStr, OsString};
Expand Down

0 comments on commit 2a0a7cb

Please sign in to comment.