summaryrefslogtreecommitdiff
path: root/commands/src/ls.rs
diff options
context:
space:
mode:
Diffstat (limited to 'commands/src/ls.rs')
-rw-r--r--commands/src/ls.rs95
1 files changed, 0 insertions, 95 deletions
diff --git a/commands/src/ls.rs b/commands/src/ls.rs
deleted file mode 100644
index 1252255..0000000
--- a/commands/src/ls.rs
+++ /dev/null
@@ -1,95 +0,0 @@
-use alloc::format;
-use alloc::string::{String, ToString};
-use uefi::proto::console::text::Color;
-use uefi::proto::media::file::FileAttribute;
-use toolkit::error::{display_error, Error};
-use toolkit::Toolkit;
-use crate::parser::Command;
-
-pub fn run(tk: &mut Toolkit, command: Command) {
- let path = tk.get_cwd().replace('/', "\\");
-
- match command.names.len() {
- 1 => {
- tk.resolve_path(&command.names[0]);
- },
- x if x > 1 => {
- display_error(tk, Error::E08);
- },
- _ => {}
- }
-
- let result = tk.scandir(&path.to_string());
- tk.color(Color::Cyan, Color::Black);
- tk.print("\nAttrib");
- tk.color(Color::Yellow, Color::Black);
- tk.print(" │ ");
- tk.color(Color::Cyan, Color::Black);
- tk.print("File name");
- tk.color(Color::Yellow, Color::Black);
- tk.print(" │ ");
- tk.color(Color::Cyan, Color::Black);
- tk.print("Size");
- tk.color(Color::Yellow, Color::Black);
- tk.print(" │ ");
- tk.color(Color::Cyan, Color::Black);
- tk.print("Bytes\r\n");
- tk.color(Color::Yellow, Color::Black);
- tk.println("───────┼──────────────────────────────┼──────────┼──────────");
- tk.color(Color::LightGray, Color::Black);
-
- for i in result {
- let item = i.unwrap();
- let attr = item.attribute();
-
- tk.print(&format!("{}{}{}{}{}",
- if attr.contains(FileAttribute::DIRECTORY) {
- "D"
- } else {
- "-"
- },
- if attr.contains(FileAttribute::ARCHIVE) {
- "A"
- } else {
- "-"
- },
- if attr.contains(FileAttribute::HIDDEN) {
- "H"
- } else {
- "-"
- },
- if attr.contains(FileAttribute::SYSTEM) {
- "S"
- } else {
- "-"
- },
- if attr.contains(FileAttribute::READ_ONLY) {
- "R"
- } else {
- "-"
- }
- ));
-
- let mut s = item.file_name().to_string();
- if s.len() > 30 {
- s = String::from(&s[0..30]);
- }
- tk.color(Color::Yellow, Color::Black);
- tk.print(" │ ");
- tk.color(Color::LightGray, Color::Black);
- tk.print(&format!("{}{}", s, " ".repeat(29 - s.len())));
-
- tk.color(Color::Yellow, Color::Black);
- tk.print("│ ");
- tk.color(Color::LightGray, Color::Black);
- let size = tk.make_readable(item.file_size());
- tk.print(&format!("{}{}", " ".repeat(8 - size.len()), size));
- tk.color(Color::Yellow, Color::Black);
- tk.print(" │ ");
- tk.color(Color::LightGray, Color::Black);
- tk.print(&format!("{}", item.file_size()));
- tk.print("\r\n");
- }
-
- tk.println("");
-} \ No newline at end of file