diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2011-11-27 11:22:36 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2011-11-27 11:22:36 -0500 |
commit | 3d6790614bb0dc776e02a95835e5c274263d1d1a (patch) | |
tree | aad032777fccb7fbdc80551a6f89f4bb4845a510 /shell/bin/ls.php | |
parent | 66c84cedfb411ad6ca0508d9f45d6d33c8ad474d (diff) |
This zip file was identified as ltshell-3.zip
Diffstat (limited to 'shell/bin/ls.php')
-rw-r--r-- | shell/bin/ls.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/shell/bin/ls.php b/shell/bin/ls.php new file mode 100644 index 0000000..fa01f2e --- /dev/null +++ b/shell/bin/ls.php @@ -0,0 +1,34 @@ +<?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"; + } + sort($files); + echo implode("\n",$files)."\n"; + closedir($dh); + } + } else { + echo $name."\n"; + } + } else { + echo $me.': file does not exist: `'.$name."'\n"; + $ret++; + } + } + return $ret; +} |