Explorar o código

Merge pull request #68 from mneumann/dragonfly

Fix compile for DragonflyBSD and nightly rust
Ben S %!s(int64=10) %!d(string=hai) anos
pai
achega
fdc4507973
Modificáronse 5 ficheiros con 47 adicións e 46 borrados
  1. 2 33
      src/feature/mod.rs
  2. 32 0
      src/feature/xattr_dummy.rs
  3. 8 8
      src/file.rs
  4. 4 4
      src/options.rs
  5. 1 1
      src/term.rs

+ 2 - 33
src/feature/mod.rs

@@ -6,39 +6,8 @@
 #[cfg(target_os = "linux")] mod xattr_linux;
 #[cfg(target_os = "linux")] pub use self::xattr_linux::Attribute;
 
-#[cfg(not(any(target_os = "macos", target_os = "linux")))] use std::old_io as io;
-#[cfg(not(any(target_os = "macos", target_os = "linux")))]
-
-
-#[derive(Clone)]
-pub struct Attribute;
-
-#[cfg(not(any(target_os = "macos", target_os = "linux")))]
-impl Attribute {
-
-    /// Getter for name
-    pub fn name(&self) -> &str {
-        unimplemented!()
-    }
-
-    /// Getter for size
-    pub fn size(&self) -> usize {
-        unimplemented!()
-    }
-
-    /// Lists the extended attributes. Follows symlinks like `metadata`
-    pub fn list(_: &Path) -> io::IoResult<Vec<Attribute>> {
-        Ok(Vec::new())
-    }
-
-    /// Lists the extended attributes. Does not follow symlinks like `symlink_metadata`
-    pub fn llist(_: &Path) -> io::IoResult<Vec<Attribute>> {
-        Ok(Vec::new())
-    }
-
-    pub fn feature_implemented() -> bool { false }
-}
-
+#[cfg(not(any(target_os = "macos", target_os = "linux")))] mod xattr_dummy;
+#[cfg(not(any(target_os = "macos", target_os = "linux")))] pub use self::xattr_dummy::Attribute;
 
 // Git support
 

+ 32 - 0
src/feature/xattr_dummy.rs

@@ -0,0 +1,32 @@
+use std::io;
+use std::path::Path;
+
+#[derive(Clone)]
+pub struct Attribute;
+
+impl Attribute {
+
+    /// Getter for name
+    pub fn name(&self) -> &str {
+        unimplemented!()
+    }
+
+    /// Getter for size
+    pub fn size(&self) -> usize {
+        unimplemented!()
+    }
+
+    /// Lists the extended attributes. Follows symlinks like `metadata`
+    pub fn list(_: &Path) -> io::Result<Vec<Attribute>> {
+        Ok(Vec::new())
+    }
+
+    /// Lists the extended attributes. Does not follow symlinks like `symlink_metadata`
+    pub fn llist(_: &Path) -> io::Result<Vec<Attribute>> {
+        Ok(Vec::new())
+    }
+
+    pub fn feature_implemented() -> bool { false }
+}
+
+

+ 8 - 8
src/file.rs

@@ -223,7 +223,7 @@ impl<'dir> File<'dir> {
     /// with multiple links much more often. Thus, it should get highlighted
     /// more attentively.
     pub fn links(&self) -> f::Links {
-        let count = self.metadata.as_raw().nlink();
+        let count = self.metadata.nlink();
 
         f::Links {
             count: count,
@@ -233,7 +233,7 @@ impl<'dir> File<'dir> {
 
     /// This file's inode.
     pub fn inode(&self) -> f::Inode {
-        f::Inode(self.metadata.as_raw().ino())
+        f::Inode(self.metadata.ino())
     }
 
     /// This file's number of filesystem blocks.
@@ -241,7 +241,7 @@ impl<'dir> File<'dir> {
     /// (Not the size of each block, which we don't actually report on)
     pub fn blocks(&self) -> f::Blocks {
         if self.is_file() || self.is_link() {
-            f::Blocks::Some(self.metadata.as_raw().blocks())
+            f::Blocks::Some(self.metadata.blocks())
         }
         else {
             f::Blocks::None
@@ -250,12 +250,12 @@ impl<'dir> File<'dir> {
 
     /// The ID of the user that own this file.
     pub fn user(&self) -> f::User {
-        f::User(self.metadata.as_raw().uid())
+        f::User(self.metadata.uid())
     }
 
     /// The ID of the group that owns this file.
     pub fn group(&self) -> f::Group {
-        f::Group(self.metadata.as_raw().gid())
+        f::Group(self.metadata.gid())
     }
 
     /// This file's size, if it's a regular file.
@@ -275,9 +275,9 @@ impl<'dir> File<'dir> {
     /// One of this file's timestamps, as a number in seconds.
     pub fn timestamp(&self, time_type: TimeType) -> f::Time {
         let time_in_seconds = match time_type {
-            TimeType::FileAccessed => self.metadata.as_raw().atime(),
-            TimeType::FileModified => self.metadata.as_raw().mtime(),
-            TimeType::FileCreated  => self.metadata.as_raw().ctime(),
+            TimeType::FileAccessed => self.metadata.atime(),
+            TimeType::FileModified => self.metadata.mtime(),
+            TimeType::FileCreated  => self.metadata.ctime(),
         };
 
         f::Time(time_in_seconds)

+ 4 - 4
src/options.rs

@@ -132,10 +132,10 @@ impl FileFilter {
             SortField::Unsorted      => {},
             SortField::Name          => files.sort_by(|a, b| natord::compare(&*a.name, &*b.name)),
             SortField::Size          => files.sort_by(|a, b| a.metadata.len().cmp(&b.metadata.len())),
-            SortField::FileInode     => files.sort_by(|a, b| a.metadata.as_raw().ino().cmp(&b.metadata.as_raw().ino())),
-            SortField::ModifiedDate  => files.sort_by(|a, b| a.metadata.as_raw().mtime().cmp(&b.metadata.as_raw().mtime())),
-            SortField::AccessedDate  => files.sort_by(|a, b| a.metadata.as_raw().atime().cmp(&b.metadata.as_raw().atime())),
-            SortField::CreatedDate   => files.sort_by(|a, b| a.metadata.as_raw().ctime().cmp(&b.metadata.as_raw().ctime())),
+            SortField::FileInode     => files.sort_by(|a, b| a.metadata.ino().cmp(&b.metadata.ino())),
+            SortField::ModifiedDate  => files.sort_by(|a, b| a.metadata.mtime().cmp(&b.metadata.mtime())),
+            SortField::AccessedDate  => files.sort_by(|a, b| a.metadata.atime().cmp(&b.metadata.atime())),
+            SortField::CreatedDate   => files.sort_by(|a, b| a.metadata.ctime().cmp(&b.metadata.ctime())),
             SortField::Extension     => files.sort_by(|a, b| match a.ext.cmp(&b.ext) {
                 cmp::Ordering::Equal  => natord::compare(&*a.name, &*b.name),
                 order                 => order,

+ 1 - 1
src/term.rs

@@ -16,7 +16,7 @@ mod c {
     #[cfg(any(target_os = "linux", target_os = "android"))]
     static TIOCGWINSZ: c_ulong = 0x5413;
 
-    #[cfg(any(target_os = "macos", target_os = "ios"))]
+    #[cfg(any(target_os = "macos", target_os = "ios", target_os = "dragonfly"))]
     static TIOCGWINSZ: c_ulong = 0x40087468;
 
     extern {