0B instead of 0.00B
This commit is contained in:
@@ -57,6 +57,7 @@ fn print_elements(
|
||||
|
||||
for (i, e) in elements.iter().enumerate() {
|
||||
print!("│ ");
|
||||
// text.push_str("│ ");
|
||||
let mut e_string = String::new();
|
||||
if current_depth > 0 {
|
||||
add_recursive_lines(
|
||||
@@ -69,15 +70,30 @@ fn print_elements(
|
||||
}
|
||||
|
||||
e_string.push_str(e.to_string().as_str());
|
||||
print!(
|
||||
"{}",
|
||||
pad_string(
|
||||
let file_text = pad_string(
|
||||
get_slice_of_string(e_string.as_str(), name_length - 1, 0, current_depth),
|
||||
name_length,
|
||||
true
|
||||
)
|
||||
true,
|
||||
);
|
||||
|
||||
print!(
|
||||
"{}",
|
||||
file_text // if e.get_file_type() == TypeOfFile::Dir {
|
||||
// file_text.cyan().to_string()
|
||||
// } else {
|
||||
// file_text
|
||||
// }
|
||||
);
|
||||
|
||||
// text.push_str(
|
||||
// pad_string(
|
||||
// get_slice_of_string(e_string.as_str(), name_length - 1, 0, current_depth),
|
||||
// name_length,
|
||||
// true,
|
||||
// )
|
||||
// .as_str(),
|
||||
// );
|
||||
|
||||
print_size_and_creation_date(e);
|
||||
|
||||
let num_splits =
|
||||
@@ -105,7 +121,9 @@ fn print_elements(
|
||||
.as_str(),
|
||||
);
|
||||
print!("{}", pad_string(e_name, name_length + 2, true));
|
||||
// text.push_str(pad_string(e_name, name_length + 2, true).as_str());
|
||||
println!("│ │ │");
|
||||
// text.push_str("│ │ │\n");
|
||||
}
|
||||
|
||||
if e.get_file_type() == TypeOfFile::Dir && current_depth < recursive_limit {
|
||||
|
||||
@@ -59,7 +59,7 @@ pub fn get_string_length(s: &str) -> usize {
|
||||
|
||||
pub fn get_size_string(bytes: u64) -> String {
|
||||
if bytes == 0 {
|
||||
return String::from("0.00 B ");
|
||||
return String::from(" 0 B ");
|
||||
}
|
||||
let bytes_f32 = bytes as f32;
|
||||
let exp = bytes_f32.log(1024.0).floor();
|
||||
@@ -89,12 +89,12 @@ pub fn sort_elements(elements: &mut [Element], sort_by: &SortBy) {
|
||||
|
||||
// ALL ICONS MUST BE FOLLOWED BY A SPACE
|
||||
pub fn get_icon_file_type<'a>(filename: String) -> &'a str {
|
||||
let extension = filename.split('.').last().unwrap(); //.collect::<Vec<&str>>()[1..].join(".");
|
||||
let extension = filename.split('.').last().unwrap();
|
||||
match extension.to_lowercase().as_str() {
|
||||
"jpg" | "jpeg" | "png" | "bmp" | "gif" | "webp" | "svg" => " ",
|
||||
"zip" | "rar" | "7zip" | "tar" | "gz" | "tgz" => " ",
|
||||
"config" | "toml" | "yaml" | "conf" | "cfg" => " ",
|
||||
"flv" | "avi" | "mp4" | "webm" | "mov" => " ",
|
||||
"config" | "toml" | "yaml" | "conf" => " ",
|
||||
"exe" | "bat" | "dll" | "msi" => " ",
|
||||
"mp3" | "wav" | "ogg" => " ",
|
||||
"java" | "jar" => " ",
|
||||
@@ -117,11 +117,13 @@ pub fn get_icon_file_type<'a>(filename: String) -> &'a str {
|
||||
"lua" => " ",
|
||||
"php" => " ",
|
||||
"vim" => " ",
|
||||
"key" => " ",
|
||||
"rs" => " ",
|
||||
"js" => " ",
|
||||
"sh" => " ",
|
||||
"db" => " ",
|
||||
"cs" => " ",
|
||||
"md" => " ",
|
||||
"c" => " ",
|
||||
"r" => " ",
|
||||
_ => " ",
|
||||
|
||||
Reference in New Issue
Block a user