add command ls
This commit is contained in:
+1
-1
@@ -7,6 +7,6 @@ function help($commands)
|
||||
} else if (sizeof($commands) == 2 && file_get_contents("static/help/$commands[1].txt") != NULL) {
|
||||
file_put_contents("recent.txt", file_get_contents("static/help/$commands[1].txt"), FILE_APPEND);
|
||||
} else {
|
||||
file_put_contents("recent.txt", "Invalid number of arguments.<br/>", FILE_APPEND);
|
||||
file_put_contents("recent.txt", "Invalid number of arguments or command not found.<br/>", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
function ls($commands)
|
||||
{
|
||||
$pwd = file_get_contents("pwd.txt");
|
||||
if (sizeof($commands) == 1) {
|
||||
$files = scandir("fileroot" . $pwd);
|
||||
foreach ($files as $file) {
|
||||
file_put_contents("recent.txt", $file . "<br/>", FILE_APPEND);
|
||||
}
|
||||
} else {
|
||||
file_put_contents("recent.txt", "Invalid number of arguments.<br/>", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
make php
|
||||
write help.txt <command_name>.txt
|
||||
edit terminal.php
|
||||
@@ -0,0 +1,2 @@
|
||||
ls - lists the contents of a directory<br/>
|
||||
usage: ls<br/>
|
||||
@@ -2,6 +2,7 @@ cat - displays the contents of a file<br/>
|
||||
cd - changes the working directory<br/>
|
||||
clear - clears the screen<br/>
|
||||
help - displays this help message<br/>
|
||||
ls - lists the contents of a directory<br/>
|
||||
mkdir - creates a new directory<br/>
|
||||
pwd - shows the working directory<br/>
|
||||
rm - deletes a file or directory<br/>
|
||||
|
||||
@@ -64,6 +64,9 @@ if (!opendir("fileroot")) {
|
||||
} else if ($commands[0] == "cat") {
|
||||
include "commands/cat.php";
|
||||
cat($commands);
|
||||
} else if ($commands[0] == "ls") {
|
||||
include "commands/ls.php";
|
||||
ls($commands);
|
||||
} else {
|
||||
file_put_contents("recent.txt", "Unknown command.<br/>try 'help' or 'help [command]'<br/>", FILE_APPEND);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user