summaryrefslogtreecommitdiff
path: root/Source/Kernel/Core
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-09-15 18:59:24 +0200
committerAlexis211 <alexis211@gmail.com>2009-09-15 18:59:24 +0200
commite2e0f21d932224434cb6121165dc00f0c1bb3bdd (patch)
treed54e5d2c6cfb3aa734d974728ee1fe5ac97482a2 /Source/Kernel/Core
parent0211692f62cdd934ea9c802bc5b09d63eb4399af (diff)
downloadMelon-e2e0f21d932224434cb6121165dc00f0c1bb3bdd.tar.gz
Melon-e2e0f21d932224434cb6121165dc00f0c1bb3bdd.zip
cat command now uses the File class.
Diffstat (limited to 'Source/Kernel/Core')
-rw-r--r--Source/Kernel/Core/kmain.wtf.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/Source/Kernel/Core/kmain.wtf.cpp b/Source/Kernel/Core/kmain.wtf.cpp
index 6dc37ee..89932e3 100644
--- a/Source/Kernel/Core/kmain.wtf.cpp
+++ b/Source/Kernel/Core/kmain.wtf.cpp
@@ -23,6 +23,7 @@
#include <VFS/FileNode.class.h>
#include <VFS/VFS.ns.h>
#include <VFS/DirectoryNode.class.h>
+#include <VFS/File.class.h>
#include <Ressources/logo.cd>
#include <Ressources/keymap-fr.wtf.c>
@@ -81,7 +82,7 @@ void kmain(multiboot_info_t* mbd, u32int magic) {
IDT::init(); OK(kvt);
PROCESSING(kvt, "Initializing paging...");
- u32int totalRam = ((mbd->mem_upper + 1024) * 1024);
+ u32int totalRam = ((mbd->mem_upper + mbd->mem_lower) * 1024);
PhysMem::initPaging(totalRam); OK(kvt);
INFO(kvt); *kvt << "Total ram : " << (s32int)(totalRam / 1024) << "k (" << (s32int)(totalRam / (1024 * 1024)) << "M).\n";
@@ -177,18 +178,15 @@ void kmain(multiboot_info_t* mbd, u32int magic) {
} else if (tokens[0] == "cat") {
if (tokens.size() == 1) *kvt << "Meow.\n";
for (u32int i = 1; i < tokens.size(); i++) {
- FSNode* n = VFS::find(tokens[i], cwd);
- if (n == NULL) {
- *kvt << "No such file : " << tokens[i] << "\n";
- } else if (n->type() != NT_FILE) {
- *kvt << "Not a file : " << tokens[i] << "\n";
- } else {
- FileNode* f = (FileNode*) n;
- u8int *buff = (u8int*)Mem::kalloc(f->getLength() + 1);
- f->read(0, f->getLength(), buff);
- buff[f->getLength()] = 0;
+ File f(tokens[i], FM_READ, cwd);
+ if (f.valid()) {
+ u8int *buff = (u8int*)Mem::kalloc(f.length() + 1);
+ f.read(f.length(), buff);
+ buff[f.length()] = 0;
*kvt << String((const char*) buff);
Mem::kfree(buff);
+ } else {
+ *kvt << "Error reading from file " << tokens[i] << "\n";
}
}
} else if (tokens[0] == "pwd") {