summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-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
6 files changed, 43 insertions, 6 deletions
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