Re-implement no-longer-missing metadata fields

This commit is contained in:
Ben S 2015-05-03 12:46:05 +01:00
parent d7a2974494
commit 41aadaeab4
4 changed files with 23 additions and 23 deletions

28
Cargo.lock generated
View File

@ -13,7 +13,7 @@ dependencies = [
"number_prefix 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "number_prefix 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"pad 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "pad 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"users 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "users 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -40,7 +40,7 @@ dependencies = [
[[package]] [[package]]
name = "gcc" name = "gcc"
version = "0.3.4" version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
@ -54,7 +54,7 @@ dependencies = [
[[package]] [[package]]
name = "git2" name = "git2"
version = "0.2.9" version = "0.2.9"
source = "git+https://github.com/alexcrichton/git2-rs.git#315a6f2e6f20babaa2f48416de9a14d15420cf1b" source = "git+https://github.com/alexcrichton/git2-rs.git#42776b31a4b3755df95ec79e6bcaffcee83a93f1"
dependencies = [ dependencies = [
"bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -70,12 +70,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "libgit2-sys" name = "libgit2-sys"
version = "0.2.12" version = "0.2.12"
source = "git+https://github.com/alexcrichton/git2-rs.git#315a6f2e6f20babaa2f48416de9a14d15420cf1b" source = "git+https://github.com/alexcrichton/git2-rs.git#42776b31a4b3755df95ec79e6bcaffcee83a93f1"
dependencies = [ dependencies = [
"libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libssh2-sys 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "libssh2-sys 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"libz-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -89,12 +89,12 @@ dependencies = [
[[package]] [[package]]
name = "libssh2-sys" name = "libssh2-sys"
version = "0.1.18" version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libz-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "libz-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", "openssl-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -140,7 +140,7 @@ version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -161,10 +161,10 @@ dependencies = [
[[package]] [[package]]
name = "openssl-sys" name = "openssl-sys"
version = "0.6.1" version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"gcc 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "gcc 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"libressl-pnacl-sys 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "libressl-pnacl-sys 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -214,7 +214,7 @@ dependencies = [
[[package]] [[package]]
name = "rustc-serialize" name = "rustc-serialize"
version = "0.3.13" version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
@ -236,12 +236,12 @@ version = "0.2.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "users" name = "users"
version = "0.3.2" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -17,7 +17,7 @@ num_cpus = "*"
number_prefix = "0.2.3" number_prefix = "0.2.3"
pad = "0.1.1" pad = "0.1.1"
unicode-width = "*" unicode-width = "*"
users = "0.3.1" users = "0.4.0"
[features] [features]
default = [ "git" ] default = [ "git" ]

View File

@ -3,7 +3,7 @@ use std::env::current_dir;
use std::fs; use std::fs;
use std::io; use std::io;
use std::os::unix; use std::os::unix;
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::{MetadataExt, PermissionsExt};
use std::path::{Component, Path, PathBuf}; use std::path::{Component, Path, PathBuf};
use ansi_term::{ANSIString, ANSIStrings, Colour, Style}; use ansi_term::{ANSIString, ANSIStrings, Colour, Style};
@ -245,7 +245,7 @@ impl<'a> File<'a> {
/// This file's number of hard links as a coloured string. /// This file's number of hard links as a coloured string.
fn hard_links(&self, locale: &locale::Numeric) -> Cell { fn hard_links(&self, locale: &locale::Numeric) -> Cell {
let style = if self.has_multiple_links() { Red.on(Yellow) } else { Red.normal() }; let style = if self.has_multiple_links() { Red.on(Yellow) } else { Red.normal() };
Cell::paint(style, &locale.format_int(0 /*self.stat.unstable.nlink*/ as isize)[..]) Cell::paint(style, &locale.format_int(self.stat.as_raw().nlink())[..])
} }
/// Whether this is a regular file with more than one link. /// Whether this is a regular file with more than one link.
@ -254,19 +254,19 @@ impl<'a> File<'a> {
/// while you can come across directories and other types with multiple /// while you can come across directories and other types with multiple
/// links much more often. /// links much more often.
fn has_multiple_links(&self) -> bool { fn has_multiple_links(&self) -> bool {
self.is_file() && (0 /*self.stat.unstable.nlink*/) > 1 self.is_file() && self.stat.as_raw().nlink() > 1
} }
/// This file's inode as a coloured string. /// This file's inode as a coloured string.
fn inode(&self) -> Cell { fn inode(&self) -> Cell {
let inode = 0i32; /* self.stat.unstable.inode */ let inode = self.stat.as_raw().ino();
Cell::paint(Purple.normal(), &inode.to_string()[..]) Cell::paint(Purple.normal(), &inode.to_string()[..])
} }
/// This file's number of filesystem blocks (if available) as a coloured string. /// This file's number of filesystem blocks (if available) as a coloured string.
fn blocks(&self, locale: &locale::Numeric) -> Cell { fn blocks(&self, locale: &locale::Numeric) -> Cell {
if self.is_file() || self.is_link() { if self.is_file() || self.is_link() {
Cell::paint(Cyan.normal(), &locale.format_int(0 /*self.stat.unstable.blocks*/)[..]) Cell::paint(Cyan.normal(), &locale.format_int(self.stat.as_raw().blocks())[..])
} }
else { else {
Cell { text: GREY.paint("-").to_string(), length: 1 } Cell { text: GREY.paint("-").to_string(), length: 1 }
@ -279,7 +279,7 @@ impl<'a> File<'a> {
/// instead. This usually happens when a user is deleted, but still owns /// instead. This usually happens when a user is deleted, but still owns
/// files. /// files.
fn user<U: Users>(&self, users_cache: &mut U) -> Cell { fn user<U: Users>(&self, users_cache: &mut U) -> Cell {
let uid = 0; // self.stat.unstable.uid as u32 let uid = self.stat.as_raw().uid();
let user_name = match users_cache.get_user_by_uid(uid) { let user_name = match users_cache.get_user_by_uid(uid) {
Some(user) => user.name, Some(user) => user.name,
@ -294,7 +294,7 @@ impl<'a> File<'a> {
/// ///
/// As above, if not present, it formats the gid as a number instead. /// As above, if not present, it formats the gid as a number instead.
fn group<U: Users>(&self, users_cache: &mut U) -> Cell { fn group<U: Users>(&self, users_cache: &mut U) -> Cell {
let gid = 0; // self.stat.unstable.gid as u32; let gid = self.stat.as_raw().gid();
let mut style = Plain; let mut style = Plain;
let group_name = match users_cache.get_group_by_gid(gid as u32) { let group_name = match users_cache.get_group_by_gid(gid as u32) {

View File

@ -1,4 +1,4 @@
#![feature(collections, convert, core, exit_status, fs_ext, fs_mode, fs_time, io, libc, os, scoped, std_misc)] #![feature(collections, convert, core, exit_status, fs_ext, fs_mode, fs_time, io, libc, metadata_ext, os, scoped, std_misc)]
#![allow(deprecated)] #![allow(deprecated)]
// Other platforms than macos don't need std_misc but you can't // Other platforms than macos don't need std_misc but you can't