summaryrefslogtreecommitdiff
path: root/shell/bin/ls.php
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-11-27 11:23:55 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-11-27 11:23:55 -0500
commitfb0380f48203a11584773f3db335eaadd9cc6fdf (patch)
tree98f7eb36ed8a3ec99c1cba5c9c0742af8931783b /shell/bin/ls.php
parent3d6790614bb0dc776e02a95835e5c274263d1d1a (diff)
This zip file was identified as ltshell-3.5.zip
Diffstat (limited to 'shell/bin/ls.php')
-rw-r--r--shell/bin/ls.php55
1 files changed, 29 insertions, 26 deletions
diff --git a/shell/bin/ls.php b/shell/bin/ls.php
index fa01f2e..aa938c1 100644
--- a/shell/bin/ls.php
+++ b/shell/bin/ls.php
@@ -1,34 +1,37 @@
<?php
-function main($args) {
- if (count($args)<2) {
- $args[]='.';
- }
- $ret=0;
- $me = array_shift($args);
- foreach ($args as $name) {
- if (file_exists($name)) {
- if (is_dir($name)) {
- @$dh = opendir($name);
- if ($dh === false) {
- echo $me.': can not open directory: `'.$name."'\n";
- $ret++;
- } else {
- if (count($args)>1) { echo $name.":\n"; }
- $files = array();
- while (false !== ($file = readdir($dh))) {
- $files[]="$file";
+class p_ls extends prog {
+ public static function main($args, $env) {
+ if (count($args)<2) {
+ $args[]='.';
+ }
+ $ret=0;
+ $me = array_shift($args);
+ foreach ($args as $name) {
+ if (file_exists($name)) {
+ if (is_dir($name)) {
+ @$dh = opendir($name);
+ if ($dh === false) {
+ echo $me.': can not open directory: `'.$name."'\n";
+ $ret++;
+ } else {
+ if (count($args)>1) { echo $name.":\n"; }
+ $files = array();
+ while (false !== ($file = readdir($dh))) {
+ $files[]="$file";
+ }
+ sort($files);
+ echo implode("\n",$files)."\n";
+ closedir($dh);
}
- sort($files);
- echo implode("\n",$files)."\n";
- closedir($dh);
+ } else {
+ echo $name."\n";
}
} else {
- echo $name."\n";
+ echo $me.': file does not exist: `'.$name."'\n";
+ $ret++;
}
- } else {
- echo $me.': file does not exist: `'.$name."'\n";
- $ret++;
}
+ return $ret;
}
- return $ret;
}
+