|
@ -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 |",
|
|
|
|
|
|
|
|
|
"{} | dir | size | modified | accessed |",
|
|
|
right_padding(" filename", 20)
|
|
|
right_padding(" filename", 20)
|
|
|
);
|
|
|
);
|
|
|
|
|
|
|
|
@ -42,6 +42,11 @@ impl Builtin for Ls { |
|
|
Err(_) => Local::now(),
|
|
|
Err(_) => Local::now(),
|
|
|
};
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let accessed: DateTime<Local> = match metadata.accessed() {
|
|
|
|
|
|
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"
|
|
@ -52,7 +57,14 @@ impl Builtin for Ls { |
|
|
}
|
|
|
}
|
|
|
println!(
|
|
|
println!(
|
|
|
"{}",
|
|
|
"{}",
|
|
|
format_line(20, &file_name, file_type, metadata.len(), modified)
|
|
|
|
|
|
|
|
|
format_line(
|
|
|
|
|
|
20,
|
|
|
|
|
|
&file_name,
|
|
|
|
|
|
file_type,
|
|
|
|
|
|
metadata.len(),
|
|
|
|
|
|
modified,
|
|
|
|
|
|
accessed
|
|
|
|
|
|
)
|
|
|
);
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
Ok(())
|
|
|
Ok(())
|
|
@ -86,13 +98,15 @@ fn format_line( |
|
|
file_type: &str,
|
|
|
file_type: &str,
|
|
|
file_size: u64,
|
|
|
file_size: u64,
|
|
|
modified: DateTime<Local>,
|
|
|
modified: DateTime<Local>,
|
|
|
|
|
|
accessed: 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)
|
|
|
)
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|