mirror of
https://github.com/uutils/coreutils
synced 2024-12-15 07:42:48 +00:00
du: use blocks to remove some cfgs
This commit is contained in:
parent
1818632d7c
commit
2571af8ede
1 changed files with 34 additions and 31 deletions
|
@ -137,11 +137,12 @@ impl Stat {
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
|
{
|
||||||
let file_info = FileInfo {
|
let file_info = FileInfo {
|
||||||
file_id: metadata.ino() as u128,
|
file_id: metadata.ino() as u128,
|
||||||
dev_id: metadata.dev(),
|
dev_id: metadata.dev(),
|
||||||
};
|
};
|
||||||
#[cfg(not(windows))]
|
|
||||||
return Ok(Self {
|
return Ok(Self {
|
||||||
path: path.to_path_buf(),
|
path: path.to_path_buf(),
|
||||||
is_dir: metadata.is_dir(),
|
is_dir: metadata.is_dir(),
|
||||||
|
@ -153,25 +154,27 @@ impl Stat {
|
||||||
accessed: metadata.atime() as u64,
|
accessed: metadata.atime() as u64,
|
||||||
modified: metadata.mtime() as u64,
|
modified: metadata.mtime() as u64,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
let size_on_disk = get_size_on_disk(path);
|
let size_on_disk = get_size_on_disk(path);
|
||||||
#[cfg(windows)]
|
|
||||||
let file_info = get_file_info(path);
|
let file_info = get_file_info(path);
|
||||||
#[cfg(windows)]
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
path: path.to_path_buf(),
|
path: path.to_path_buf(),
|
||||||
is_dir: metadata.is_dir(),
|
is_dir: metadata.is_dir(),
|
||||||
size: if path.is_dir() { 0 } else { metadata.len() },
|
size: if path.is_dir() { 0 } else { metadata.len() },
|
||||||
blocks: size_on_disk / 1024 * 2,
|
blocks: size_on_disk / 1024 * 2,
|
||||||
inode: file_info,
|
|
||||||
inodes: 1,
|
inodes: 1,
|
||||||
|
inode: file_info,
|
||||||
created: windows_creation_time_to_unix_time(metadata.creation_time()),
|
created: windows_creation_time_to_unix_time(metadata.creation_time()),
|
||||||
accessed: windows_time_to_unix_time(metadata.last_access_time()),
|
accessed: windows_time_to_unix_time(metadata.last_access_time()),
|
||||||
modified: windows_time_to_unix_time(metadata.last_write_time()),
|
modified: windows_time_to_unix_time(metadata.last_write_time()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
// https://doc.rust-lang.org/std/os/windows/fs/trait.MetadataExt.html#tymethod.last_access_time
|
// https://doc.rust-lang.org/std/os/windows/fs/trait.MetadataExt.html#tymethod.last_access_time
|
||||||
|
|
Loading…
Reference in a new issue