|
@ -19,7 +19,7 @@ impl Builtin for Ls { |
|
|
//for entry in entries.by_ref().into_iter() {}
|
|
|
//for entry in entries.by_ref().into_iter() {}
|
|
|
|
|
|
|
|
|
println!(
|
|
|
println!(
|
|
|
"{} | dir | size | modified | accessed |",
|
|
|
|
|
|
|
|
|
"{} | dir | size | modified | accessed | created |",
|
|
|
right_padding(" filename", 20)
|
|
|
right_padding(" filename", 20)
|
|
|
);
|
|
|
);
|
|
|
|
|
|
|
|
@ -47,6 +47,11 @@ impl Builtin for Ls { |
|
|
Err(_) => Local::now(),
|
|
|
Err(_) => Local::now(),
|
|
|
};
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let created: DateTime<Local> = match metadata.created() {
|
|
|
|
|
|
Ok(t) => DateTime::from(t),
|
|
|
|
|
|
Err(_) => Local::now(),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
let mut file_type = "unknown";
|
|
|
let mut file_type = "unknown";
|
|
|
if metadata.file_type().is_dir() {
|
|
|
if metadata.file_type().is_dir() {
|
|
|
file_type = "dir"
|
|
|
file_type = "dir"
|
|
@ -63,7 +68,8 @@ impl Builtin for Ls { |
|
|
file_type,
|
|
|
file_type,
|
|
|
metadata.len(),
|
|
|
metadata.len(),
|
|
|
modified,
|
|
|
modified,
|
|
|
accessed
|
|
|
|
|
|
|
|
|
accessed,
|
|
|
|
|
|
created
|
|
|
)
|
|
|
)
|
|
|
);
|
|
|
);
|
|
|
}
|
|
|
}
|
|
@ -99,14 +105,16 @@ fn format_line( |
|
|
file_size: u64,
|
|
|
file_size: u64,
|
|
|
modified: DateTime<Local>,
|
|
|
modified: DateTime<Local>,
|
|
|
accessed: DateTime<Local>,
|
|
|
accessed: DateTime<Local>,
|
|
|
|
|
|
created: DateTime<Local>,
|
|
|
) -> String {
|
|
|
) -> String {
|
|
|
format!(
|
|
|
format!(
|
|
|
"{} | {:4} | {:6} | {} | {} |",
|
|
|
|
|
|
|
|
|
"{} | {:4} | {:6} | {} | {} | {} |",
|
|
|
right_padding(file_name, max_name_len),
|
|
|
right_padding(file_name, max_name_len),
|
|
|
file_type,
|
|
|
file_type,
|
|
|
format_filesize(file_size),
|
|
|
format_filesize(file_size),
|
|
|
right_padding(&format_date(modified), 10),
|
|
|
right_padding(&format_date(modified), 10),
|
|
|
right_padding(&format_date(accessed), 10)
|
|
|
|
|
|
|
|
|
right_padding(&format_date(accessed), 10),
|
|
|
|
|
|
right_padding(&format_date(created), 10),
|
|
|
)
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|