summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Grub-menu-fdd.cfg2
-rw-r--r--Makefile16
-rw-r--r--Source/Applications/Demos/GOL.cpp2
-rw-r--r--Source/Applications/Shell/Shell.class.cpp12
-rw-r--r--Source/Kernel/Devices/Display/VESADisplay.class.cpp4
-rw-r--r--Source/Library/Common/FileStream.class.cpp1
-rw-r--r--Source/Library/Userland/App/StreamApp.proto.cpp8
-rw-r--r--Source/Library/Userland/Binding/FSNode.class.h22
8 files changed, 52 insertions, 15 deletions
diff --git a/Grub-menu-fdd.cfg b/Grub-menu-fdd.cfg
index 37bcfb0..e759628 100644
--- a/Grub-menu-fdd.cfg
+++ b/Grub-menu-fdd.cfg
@@ -17,7 +17,7 @@ module /System/Init.rfs
title Melon without init, boot on initramfs
root (fd0)
-kernel /System/Melon.ke init: root:ramfs:0
+kernel /System/Melon.ke init:/Shell.app root:ramfs:0
module /System/Init.rfs
title Game of life simulator
diff --git a/Makefile b/Makefile
index 67a1d02..1c17615 100644
--- a/Makefile
+++ b/Makefile
@@ -4,19 +4,19 @@ Projects = Kernel Library Tools/MakeRamFS Applications/Shell Applications/PaperW
Kernel = Source/Kernel/Melon.ke
RamFS = Init.rfs
-RamFSFiles = :/System :/System/Configuration :/System/Keymaps \
+RamFSFiles = :/System :/System/Configuration :/System/Keymaps :/Applets \
Source/Kernel/Ressources/Configuration/Users:/System/Configuration/Users \
Source/Kernel/Ressources/Configuration/Groups:/System/Configuration/Groups \
Source/Kernel/Ressources/Keymaps/fr.mkm:/System/Keymaps/fr.mkm \
Source/Kernel/Ressources/Texts/Welcome.txt:/Welcome.txt \
Source/Applications/Shell/Shell:/Shell.app \
- Source/Applications/Shell/Help.txt:/Shell-Help.txt \
- Source/Applications/Shell/Applets/cat:/cat \
- Source/Applications/Shell/Applets/halt:/halt \
- Source/Applications/Shell/Applets/reboot:/reboot \
- Source/Applications/Shell/Applets/uptime:/uptime \
- Source/Applications/Shell/Applets/free:/free \
- Source/Applications/Shell/Applets/ls:/ls \
+ Source/Applications/Shell/Help.txt:/Help.txt \
+ Source/Applications/Shell/Applets/cat:/Applets/cat \
+ Source/Applications/Shell/Applets/halt:/Applets/halt \
+ Source/Applications/Shell/Applets/reboot:/Applets/reboot \
+ Source/Applications/Shell/Applets/uptime:/Applets/uptime \
+ Source/Applications/Shell/Applets/free:/Applets/free \
+ Source/Applications/Shell/Applets/ls:/Applets/ls \
Source/Kernel/Ressources/Graphics/logo.text.cxd:/Melon-logo
Files = $(Kernel) $(RamFS)
diff --git a/Source/Applications/Demos/GOL.cpp b/Source/Applications/Demos/GOL.cpp
index 48d728b..70655a9 100644
--- a/Source/Applications/Demos/GOL.cpp
+++ b/Source/Applications/Demos/GOL.cpp
@@ -45,7 +45,7 @@ int GOL::run() {
}
}
}
- outvt << MVT::movecsr(0, 0);
+ outvt << MVT::movecsr(0, 0) << FLUSH;
outvt.write(tmp.toString()); //BYPASS buffering
outvt<< "Press Ctrl+h for help" << FLUSH;
diff --git a/Source/Applications/Shell/Shell.class.cpp b/Source/Applications/Shell/Shell.class.cpp
index 4bc8e11..1b7f25e 100644
--- a/Source/Applications/Shell/Shell.class.cpp
+++ b/Source/Applications/Shell/Shell.class.cpp
@@ -32,6 +32,10 @@ int Shell::run() {
{"", 0}
};
+ String dn = FS::dirname(pr.argv(0));
+ FSNode shellDir = (dn.empty() ? FS::cwdNode() : FS::find(dn, FS::cwdNode()));
+ String appletsDir = FS::find("Applets", shellDir).path() + "/";
+
setupVars();
cwd = FS::cwdNode();
@@ -84,8 +88,10 @@ int Shell::run() {
} else if (cmd[0] == "help") {
Vector<String> args;
args.push("cat");
- args.push("/Applications/Shell/Help.txt");
- appRun("cat", args);
+ args.push(shellDir.path());
+ if (args.back() != "/") args.back() += "/";
+ args.back() += "Help.txt";
+ if (!appRun(appletsDir + "cat", args)) outvt << "Could not find cat command to display help file\n";
} else if (cmd[0] == "echo") {
for (u32int i = 1; i < cmd.size(); i++) {
if (i > 1) outvt << " ";
@@ -108,7 +114,7 @@ int Shell::run() {
i++;
}
if (!found) {
- if (!appRun(cmd[0], cmd))
+ if (!appRun(appletsDir + cmd[0], cmd))
outvt << "Unknown command : " << cmd[0] << "\n";
}
}
diff --git a/Source/Kernel/Devices/Display/VESADisplay.class.cpp b/Source/Kernel/Devices/Display/VESADisplay.class.cpp
index 11b0882..1025319 100644
--- a/Source/Kernel/Devices/Display/VESADisplay.class.cpp
+++ b/Source/Kernel/Devices/Display/VESADisplay.class.cpp
@@ -253,9 +253,9 @@ void VESADisplay::drawChar(u16int line, u16int col, WChar c, u8int color) {
if (m_pixWidth == 2) memsetw((u16int*)p, bgcolor, 9);
if (m_pixWidth == 3) {
for (int i = 0; i < 9; i++) {
- p[0] = (bgcolor >> 16);
+ p[0] = (bgcolor);
p[1] = (bgcolor >> 8);
- p[2] = (bgcolor);
+ p[2] = (bgcolor >> 16);
p += 3;
}
p -= (9 * 3);
diff --git a/Source/Library/Common/FileStream.class.cpp b/Source/Library/Common/FileStream.class.cpp
index 317a023..e53d11b 100644
--- a/Source/Library/Common/FileStream.class.cpp
+++ b/Source/Library/Common/FileStream.class.cpp
@@ -62,6 +62,7 @@ FileOStream::FileOStream(const String& filename, u8int mode, u8int encoding, FSN
}
FileOStream::~FileOStream() {
+ m_file->close();
delete m_file;
}
diff --git a/Source/Library/Userland/App/StreamApp.proto.cpp b/Source/Library/Userland/App/StreamApp.proto.cpp
index b1dc7dd..90b8221 100644
--- a/Source/Library/Userland/App/StreamApp.proto.cpp
+++ b/Source/Library/Userland/App/StreamApp.proto.cpp
@@ -33,6 +33,14 @@ void StreamApp::init() {
} else {
FileIStream *f = new FileIStream(encoding, FS::cwdNode());
for (u32int i = 0; i < args.size(); i++) {
+ FSNode n = FS::find(args[i], FS::cwdNode());
+ if (!n.valid()) {
+ outvt << "File does not exist : " << args[i] << ENDL;
+ exit(-1);
+ } else if (n.type() != NT_FILE) {
+ outvt << "Not a file : " << args[i] << ENDL;
+ exit(-1);
+ }
f->appendFile(args[i]);
}
in = f;
diff --git a/Source/Library/Userland/Binding/FSNode.class.h b/Source/Library/Userland/Binding/FSNode.class.h
index a7adbc0..553197e 100644
--- a/Source/Library/Userland/Binding/FSNode.class.h
+++ b/Source/Library/Userland/Binding/FSNode.class.h
@@ -67,6 +67,28 @@ inline FSNode mkdir(String name, FSNode cwd = FSNode(0)) {
return FSNode(RessourceCaller::sCall(FNIF_OBJTYPE, FNIF_SMKDIR, (u32int)&name, cwd.resId()));
}
+inline String dirname(String filename) {
+ int lastSlash = 0;
+ for (int i = 0; i < filename.size(); i++) {
+ if (filename[i] == WChar("/")) {
+ lastSlash = i;
+ }
+ }
+ if (lastSlash == 0 and filename[0] == WChar("/")) return "/";
+ return filename.substr(0, lastSlash);
+}
+
+inline String basename(String filename) {
+ int lastSlash = 0;
+ for (int i = 0; i < filename.size(); i++) {
+ if (filename[i] == WChar("/")) {
+ lastSlash = i;
+ }
+ }
+ if (lastSlash == 0 and filename[0] != WChar("/")) return filename;
+ return filename.substr(lastSlash + 1);
+}
+
}
#endif