mirror of
https://github.com/uutils/coreutils
synced 2024-11-17 02:08:09 +00:00
du: refactor to use ? shortcut
This commit is contained in:
parent
be79a70572
commit
8f67c8fef2
1 changed files with 11 additions and 15 deletions
26
src/du/du.rs
26
src/du/du.rs
|
@ -55,21 +55,17 @@ struct Stat {
|
||||||
|
|
||||||
impl Stat {
|
impl Stat {
|
||||||
fn new(path: PathBuf) -> Result<Stat> {
|
fn new(path: PathBuf) -> Result<Stat> {
|
||||||
match fs::symlink_metadata(&path) {
|
let metadata = fs::symlink_metadata(&path)?;
|
||||||
Ok(metadata) => {
|
Ok(Stat {
|
||||||
return Ok(Stat {
|
path: path,
|
||||||
path: path,
|
is_dir: metadata.is_dir(),
|
||||||
is_dir: metadata.is_dir(),
|
size: metadata.len(),
|
||||||
size: metadata.len(),
|
blocks: metadata.blocks() as u64,
|
||||||
blocks: metadata.blocks() as u64,
|
nlink: metadata.nlink() as u64,
|
||||||
nlink: metadata.nlink() as u64,
|
created: metadata.mtime() as u64,
|
||||||
created: metadata.mtime() as u64,
|
accessed: metadata.atime() as u64,
|
||||||
accessed: metadata.atime() as u64,
|
modified: metadata.mtime() as u64,
|
||||||
modified: metadata.mtime() as u64,
|
})
|
||||||
})
|
|
||||||
}
|
|
||||||
Err(e) => Err(e),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue