diff options
Diffstat (limited to 'Source/Applications/Shell/Shell-fs.ns.cpp')
-rw-r--r-- | Source/Applications/Shell/Shell-fs.ns.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/Source/Applications/Shell/Shell-fs.ns.cpp b/Source/Applications/Shell/Shell-fs.ns.cpp index 33bc94e..5e6ae4f 100644 --- a/Source/Applications/Shell/Shell-fs.ns.cpp +++ b/Source/Applications/Shell/Shell-fs.ns.cpp @@ -5,7 +5,7 @@ namespace Shell { void ls(Vector<String>& args) { FSNode d = cwd; if (args.size() == 2) { - FSNode n = cwd.findFrom(args[1]); + FSNode n = FS::find(args[1], cwd); d = FSNode(0); if (!n.valid()) outvt << "No such directory : " << args[1] << "\n"; @@ -17,12 +17,17 @@ void ls(Vector<String>& args) { if (d.valid()) outvt << "Contents of directory " << d.path() << " :\n"; for (u32int i = 0; i < d.getLength(); i++) { FSNode n = d.getChild(i); + String perm = "rwxrwxrwx"; + u32int p = n.getPerm(); + for (u32int i = 0; i < 9; i++) { + if (((p >> i) & 1) == 0) perm[9 - i] = "-"; + } if (n.type() == NT_FILE) { - outvt << " - FILE\t" << n.getName(); + outvt << " FILE " << perm << " " << n.getName(); outvt.setCsrCol(30); outvt << (s32int)n.getLength() << " bytes.\n"; } else if (n.type() == NT_DIRECTORY) { - outvt << " - DIR\t" << n.getName() << "/"; + outvt << " DIR " << perm << " " << n.getName() << "/"; outvt.setCsrCol(30); outvt << (s32int)n.getLength() << " items.\n"; } @@ -33,7 +38,7 @@ void cd(Vector<String>& args) { if (args.size() != 2) { outvt << "Invalid argument count.\n"; } else { - FSNode ncwd = cwd.findFrom(args[1]); + FSNode ncwd = FS::find(args[1], cwd); if (!ncwd.valid()) { outvt << "No such directory : " << args[1] << "\n"; } else if (ncwd.type() == NT_DIRECTORY) { @@ -49,4 +54,13 @@ void pwd(Vector<String>& args) { outvt << "Current directory : " << cwd.path() << "\n"; } +void rm(Vector<String>& args) { + if (args.size() == 1) outvt << "No file to remove.\n"; + for (u32int i = 1; i < args.size(); i++) { + if (!FS::find(args[i], cwd).remove()) { + outvt << "Error while removing file " << args[i] << "\n"; + } + } +} + } |