summaryrefslogtreecommitdiff
path: root/Source/Applications
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-12-25 10:17:25 +0100
committerAlexis211 <alexis211@gmail.com>2009-12-25 10:17:25 +0100
commit6994f34953fac9462e899d0b2c7af64e21c92a1e (patch)
treed4b1d10a4af6f630d168791d56fef6993ed2cb22 /Source/Applications
parentc4cb32b8534610a92931d825efefd6892e8412af (diff)
downloadMelon-6994f34953fac9462e899d0b2c7af64e21c92a1e.tar.gz
Melon-6994f34953fac9462e899d0b2c7af64e21c92a1e.zip
More work
Diffstat (limited to 'Source/Applications')
-rw-r--r--Source/Applications/PaperWork/FloppyWelcome.txt3
-rw-r--r--Source/Applications/PaperWork/PaperWork.cpp11
-rw-r--r--Source/Applications/Shell/Applets/pwd.cpp15
-rw-r--r--Source/Applications/Shell/Makefile3
-rw-r--r--Source/Applications/Shell/Shell-fs.class.cpp31
-rw-r--r--Source/Applications/Shell/Shell.class.cpp31
-rw-r--r--Source/Applications/Shell/Shell.class.h3
7 files changed, 54 insertions, 43 deletions
diff --git a/Source/Applications/PaperWork/FloppyWelcome.txt b/Source/Applications/PaperWork/FloppyWelcome.txt
new file mode 100644
index 0000000..6676719
--- /dev/null
+++ b/Source/Applications/PaperWork/FloppyWelcome.txt
@@ -0,0 +1,3 @@
+Welcome to this Melon floppy !
+As loading binaries from the floppy doesn't work very well, the shell has been placed on the initrd : you have to run /Sandbox/Shell.app instead of /Applications/Shell/Shell.app
+
diff --git a/Source/Applications/PaperWork/PaperWork.cpp b/Source/Applications/PaperWork/PaperWork.cpp
index 15497e4..89cb00b 100644
--- a/Source/Applications/PaperWork/PaperWork.cpp
+++ b/Source/Applications/PaperWork/PaperWork.cpp
@@ -1,4 +1,6 @@
#include <App/ShellApp.proto.h>
+#include <Binding/FSNode.class.h>
+#include <TextFile.class.h>
#define DEFAULT_SHELL "/Applications/Shell/Shell.app"
#define PAPERWORK_PATH "/System/Applications/PaperWork.app"
@@ -33,7 +35,13 @@ int PaperWork::run() {
}
}
} else if (act == "login") {
- outvt << "Logging in to Melon\n";
+ FSNode welcome = FS::find("/System/Configuration/Welcome");
+ if (welcome.valid() && welcome.type() == NT_FILE) {
+ TextFile f("/System/Configuration/Welcome");
+ while (!f.eof()) outvt << f.readLine() << ENDL;
+ } else {
+ outvt << "Logging in to Melon\n";
+ }
String user, pw;
while (1) {
outvt << "Username: " << FLUSH;
@@ -55,6 +63,7 @@ int PaperWork::run() {
p.wait();
outvt << "\n\n";
} else {
+ outvt << "Could not run application : " << sh << ENDL;
return 1;
}
return 0;
diff --git a/Source/Applications/Shell/Applets/pwd.cpp b/Source/Applications/Shell/Applets/pwd.cpp
new file mode 100644
index 0000000..4b27eb0
--- /dev/null
+++ b/Source/Applications/Shell/Applets/pwd.cpp
@@ -0,0 +1,15 @@
+#include <App/ShellApp.proto.h>
+#include <Binding/FSNode.class.h>
+
+class pwd : public ShellApp {
+ public:
+ pwd() : ShellApp("pwd", "Shows the current directory") {
+ addFlag("f", "frugal", "Do not show 'Current directory: ' prefix", FT_BOOL, "");
+ }
+ int run() {
+ if (!bFlag("frugal")) outvt << "Current directory: ";
+ outvt << FS::cwdNode().path() << ENDL;
+ }
+};
+
+APP(pwd);
diff --git a/Source/Applications/Shell/Makefile b/Source/Applications/Shell/Makefile
index 1bce0f4..dff539c 100644
--- a/Source/Applications/Shell/Makefile
+++ b/Source/Applications/Shell/Makefile
@@ -10,7 +10,8 @@ Objects = Shell.class.o \
Shell-fs.class.o
OutFile = Shell
-Applets = Applets/cat Applets/halt Applets/reboot Applets/uptime Applets/free Applets/ls
+Applets = Applets/cat Applets/halt Applets/reboot Applets/uptime Applets/free Applets/ls \
+ Applets/pwd
all: $(OutFile) $(Applets)
echo "* Done with $(OutFile)."
diff --git a/Source/Applications/Shell/Shell-fs.class.cpp b/Source/Applications/Shell/Shell-fs.class.cpp
index bb1990d..7607f34 100644
--- a/Source/Applications/Shell/Shell-fs.class.cpp
+++ b/Source/Applications/Shell/Shell-fs.class.cpp
@@ -2,26 +2,6 @@
#include <TextFile.class.h>
#include <Binding/Process.class.h>
-void Shell::cd(Vector<String>& args) {
- if (args.size() != 2) {
- outvt << "Invalid argument count.\n";
- } else {
- FSNode ncwd = FS::find(args[1], cwd);
- if (!ncwd.valid()) {
- outvt << "No such directory : " << args[1] << "\n";
- } else if (ncwd.type() == NT_DIRECTORY) {
- ncwd.setCwd();
- cwd = ncwd;
- } else {
- outvt << "Not a directory.\n";
- }
- }
-}
-
-void Shell::pwd(Vector<String>& args) {
- outvt << "Current directory : " << cwd.path() << "\n";
-}
-
void Shell::rm(Vector<String>& args) {
if (args.size() == 1) outvt << "No file to remove.\n";
for (u32int i = 1; i < args.size(); i++) {
@@ -59,14 +39,3 @@ void Shell::wf(Vector<String>& args) {
}
}
-void Shell::run(Vector<String>& args) {
- if (args.size() == 1) {
- outvt << "Nothing to run...\n";
- } else {
- Vector<String> appargs;
- for (u32int i = 1; i < args.size(); i++) appargs.push(args[i]);
- if (!appRun(args[1], appargs)) {
- outvt << "Error while launching process.\n";
- }
- }
-}
diff --git a/Source/Applications/Shell/Shell.class.cpp b/Source/Applications/Shell/Shell.class.cpp
index 1b7f25e..971b913 100644
--- a/Source/Applications/Shell/Shell.class.cpp
+++ b/Source/Applications/Shell/Shell.class.cpp
@@ -23,12 +23,9 @@ int Shell::run() {
String name;
void (Shell::*cmd)(Vector<String>&);
} commands[] = {
- {"cd", &Shell::cd},
- {"pwd", &Shell::pwd},
{"rm", &Shell::rm},
{"mkdir", &Shell::mkdir},
{"wf", &Shell::wf},
- {"run", &Shell::run},
{"", 0}
};
@@ -70,6 +67,7 @@ int Shell::run() {
}
}
+ //Look for variables to replace
for (u32int i = 0; i < cmd.size(); i++) {
if (cmd[i][0] == WChar("$")) {
String k = cmd[i].substr(1);
@@ -82,7 +80,7 @@ int Shell::run() {
}
//Run command
- if (cmd[0] == "exit") {
+ if (cmd[0] == "exit") { // * * * INTEGRATED COMMANDS * * * //
if (cmd.size() == 1) return 0;
return cmd[1].toInt();
} else if (cmd[0] == "help") {
@@ -98,7 +96,21 @@ int Shell::run() {
outvt << cmd[i];
}
outvt << ENDL;
- } else {
+ } else if (cmd[0] == "cd") {
+ if (cmd.size() != 2) {
+ outvt << "Invalid argument count.\n";
+ } else {
+ FSNode ncwd = FS::find(cmd[1], cwd);
+ if (!ncwd.valid()) {
+ outvt << "No such directory : " << cmd[1] << ENDL;
+ } else if (ncwd.type() != NT_DIRECTORY) {
+ outvt << "Not a directory : " << cmd[1] << ENDL;
+ } else {
+ ncwd.setCwd();
+ cwd = ncwd;
+ }
+ }
+ } else { // * * * CALL AN EXTERNAL COMMAND * * * //
u32int i = 0;
bool found = false;
while (!commands[i].name.empty()) {
@@ -114,8 +126,13 @@ int Shell::run() {
i++;
}
if (!found) {
- if (!appRun(appletsDir + cmd[0], cmd))
- outvt << "Unknown command : " << cmd[0] << "\n";
+ if (FS::basename(cmd[0]) != cmd[0]) {
+ if (!appRun(cmd[0], cmd))
+ outvt << "No such file : " << cmd[0] << "\n";
+ } else {
+ if (!appRun(appletsDir + cmd[0], cmd))
+ outvt << "Unknown command : " << cmd[0] << "\n";
+ }
}
}
}
diff --git a/Source/Applications/Shell/Shell.class.h b/Source/Applications/Shell/Shell.class.h
index 94a6c2a..49208fe 100644
--- a/Source/Applications/Shell/Shell.class.h
+++ b/Source/Applications/Shell/Shell.class.h
@@ -32,12 +32,9 @@ class Shell : public ShellApp {
bool appRun(const String& name, Vector<String>& args);
- void cd(Vector<String>& args);
- void pwd(Vector<String>& args);
void rm(Vector<String>& args);
void mkdir(Vector<String>& args);
void wf(Vector<String>& args);
- void run(Vector<String>& args);
};
#endif