diff --git a/src/column.rs b/src/column.rs index 0136981..f583eeb 100644 --- a/src/column.rs +++ b/src/column.rs @@ -30,13 +30,13 @@ impl Column { pub fn header(&self) -> &'static str { match *self { Column::Permissions => "Permissions", - Column::FileName => "Name", + Column::FileName => "Name", Column::FileSize(_) => "Size", - Column::Blocks => "Blocks", - Column::User => "User", - Column::Group => "Group", - Column::HardLinks => "Links", - Column::Inode => "inode", + Column::Blocks => "Blocks", + Column::User => "User", + Column::Group => "Group", + Column::HardLinks => "Links", + Column::Inode => "inode", } } } @@ -49,7 +49,7 @@ impl Column { impl Alignment { pub fn pad_string(&self, string: &String, padding: uint) -> String { match *self { - Alignment::Left => string.clone() + " ".repeat(padding).as_slice(), + Alignment::Left => string.clone() + " ".repeat(padding).as_slice(), Alignment::Right => " ".repeat(padding) + string.as_slice(), } } diff --git a/src/dir.rs b/src/dir.rs index 3f2f140..5b531b8 100644 --- a/src/dir.rs +++ b/src/dir.rs @@ -25,12 +25,8 @@ impl<'a> Dir<'a> { for path in self.contents.iter() { match File::from_path(path, self) { - Ok(file) => { - files.push(file); - } - Err(e) => { - println!("{}: {}", path.display(), e); - } + Ok(file) => files.push(file), + Err(e) => println!("{}: {}", path.display(), e), } } diff --git a/src/options.rs b/src/options.rs index be8b040..b6651c4 100644 --- a/src/options.rs +++ b/src/options.rs @@ -52,7 +52,7 @@ impl Options { getopts::optflag("l", "long", "display extended details and attributes"), getopts::optflag("i", "inode", "show each file's inode number"), getopts::optflag("r", "reverse", "reverse order of files"), - getopts::optopt("s", "sort", "field to sort by", "WORD"), + getopts::optopt ("s", "sort", "field to sort by", "WORD"), getopts::optflag("S", "blocks", "show number of file system blocks"), getopts::optflag("x", "across", "sort multi-column view entries across"), ]; @@ -61,11 +61,11 @@ impl Options { Err(f) => Err(f), Ok(ref matches) => Ok(Options { show_invisibles: matches.opt_present("all"), - reverse: matches.opt_present("reverse"), - header: matches.opt_present("header"), - sort_field: matches.opt_str("sort").map(|word| SortField::from_word(word)).unwrap_or(SortField::Name), - dirs: if matches.free.is_empty() { vec![ ".".to_string() ] } else { matches.free.clone() }, - view: Options::view(matches), + reverse: matches.opt_present("reverse"), + header: matches.opt_present("header"), + sort_field: matches.opt_str("sort").map(|word| SortField::from_word(word)).unwrap_or(SortField::Name), + dirs: if matches.free.is_empty() { vec![ ".".to_string() ] } else { matches.free.clone() }, + view: Options::view(matches), }) } } @@ -118,7 +118,8 @@ impl Options { fn should_display(&self, f: &File) -> bool { if self.show_invisibles { true - } else { + } + else { !f.name.as_slice().starts_with(".") } } @@ -134,7 +135,7 @@ impl Options { SortField::Size => files.sort_by(|a, b| a.stat.size.cmp(&b.stat.size)), SortField::FileInode => files.sort_by(|a, b| a.stat.unstable.inode.cmp(&b.stat.unstable.inode)), SortField::Extension => files.sort_by(|a, b| { - let exts = a.ext.clone().map(|e| e.to_ascii_lower()).cmp(&b.ext.clone().map(|e| e.to_ascii_lower())); + let exts = a.ext.clone().map(|e| e.to_ascii_lower()).cmp(&b.ext.clone().map(|e| e.to_ascii_lower())); let names = a.name.to_ascii_lower().cmp(&b.name.to_ascii_lower()); exts.cmp(&names) }), diff --git a/src/sort.rs b/src/sort.rs index bd22f53..1463e27 100644 --- a/src/sort.rs +++ b/src/sort.rs @@ -22,7 +22,7 @@ impl SortPart { // numbers too big for a u64 fall back into strings. match from_str::(slice) { Some(num) => SortPart::Numeric(num), - None => SortPart::Stringular(slice.to_string()), + None => SortPart::Stringular(slice.to_string()), } } else { SortPart::Stringular(slice.to_ascii_lower()) diff --git a/src/term.rs b/src/term.rs index d0f52c6..0a3e0c4 100644 --- a/src/term.rs +++ b/src/term.rs @@ -1,4 +1,3 @@ - mod c { #![allow(non_camel_case_types)] extern crate libc; @@ -21,11 +20,10 @@ mod c { // Unfortunately the actual command is not standardised... - #[cfg(any(target_os = "linux", target_os = "android"))] - + #[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"))] static TIOCGWINSZ: c_ulong = 0x40087468; extern { diff --git a/src/unix.rs b/src/unix.rs index 784d579..35f06e8 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -116,7 +116,7 @@ impl Unix { if username == ptr::null() { return false; } - if unsafe { from_buf(username as *const u8) } == *uname { + else if unsafe { from_buf(username as *const u8) } == *uname { return true; } else {