Skip to content

Commit

Permalink
This makes exa work on other platforms than linux and macosx.
Browse files Browse the repository at this point in the history
  • Loading branch information
mneumann committed Sep 13, 2015
1 parent 6cf9274 commit 6317417
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/feature/xattr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub trait FileAttributes {
fn symlink_attributes(&self) -> io::Result<Vec<Attribute>>;
}

#[cfg(any(target_os = "macos", target_os = "linux"))]
impl FileAttributes for Path {
fn attributes(&self) -> io::Result<Vec<Attribute>> {
list_attrs(lister::Lister::new(FollowSymlinks::Yes), &self)
Expand All @@ -22,7 +23,19 @@ impl FileAttributes for Path {
}
}

#[cfg(not(any(target_os = "macos", target_os = "linux")))]
impl FileAttributes for Path {
fn attributes(&self) -> io::Result<Vec<Attribute>> {
Ok(vec![])
}

fn symlink_attributes(&self) -> io::Result<Vec<Attribute>> {
Ok(vec![])
}
}

/// Attributes which can be passed to `Attribute::list_with_flags`
#[cfg(any(target_os = "macos", target_os = "linux"))]
#[derive(Copy, Clone)]
pub enum FollowSymlinks {
Yes,
Expand All @@ -36,6 +49,7 @@ pub struct Attribute {
pub size: usize,
}

#[cfg(any(target_os = "macos", target_os = "linux"))]
pub fn list_attrs(lister: lister::Lister, path: &Path) -> io::Result<Vec<Attribute>> {
let c_path = match path.as_os_str().to_cstring() {
Some(cstring) => cstring,
Expand Down Expand Up @@ -235,4 +249,4 @@ mod lister {
}
}
}
}
}

0 comments on commit 6317417

Please sign in to comment.