diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2011-11-27 11:23:55 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2011-11-27 11:23:55 -0500 |
commit | fb0380f48203a11584773f3db335eaadd9cc6fdf (patch) | |
tree | 98f7eb36ed8a3ec99c1cba5c9c0742af8931783b /shell/bin/stat.php | |
parent | 3d6790614bb0dc776e02a95835e5c274263d1d1a (diff) |
This zip file was identified as ltshell-3.5.zip
Diffstat (limited to 'shell/bin/stat.php')
-rw-r--r-- | shell/bin/stat.php | 123 |
1 files changed, 63 insertions, 60 deletions
diff --git a/shell/bin/stat.php b/shell/bin/stat.php index 2a13743..1057e7c 100644 --- a/shell/bin/stat.php +++ b/shell/bin/stat.php @@ -1,67 +1,70 @@ - <?php - function perms($perms) { - if (($perms & 0xC000) == 0xC000) { - $info = 's'; // Socket - } elseif (($perms & 0xA000) == 0xA000) { - $info = 'l'; // Symbolic Link - } elseif (($perms & 0x8000) == 0x8000) { - $info = '-'; // Regular - } elseif (($perms & 0x6000) == 0x6000) { - $info = 'b'; // Block special - } elseif (($perms & 0x4000) == 0x4000) { - $info = 'd'; // Directory - } elseif (($perms & 0x2000) == 0x2000) { - $info = 'c'; // Character special - } elseif (($perms & 0x1000) == 0x1000) { - $info = 'p'; // FIFO pipe - } else { - $info = 'u'; // Unknown - } +<?php +class p_stat extends prog { + public static function perms($perms) { + if (($perms & 0xC000) == 0xC000) { + $info = 's'; // Socket + } elseif (($perms & 0xA000) == 0xA000) { + $info = 'l'; // Symbolic Link + } elseif (($perms & 0x8000) == 0x8000) { + $info = '-'; // Regular + } elseif (($perms & 0x6000) == 0x6000) { + $info = 'b'; // Block special + } elseif (($perms & 0x4000) == 0x4000) { + $info = 'd'; // Directory + } elseif (($perms & 0x2000) == 0x2000) { + $info = 'c'; // Character special + } elseif (($perms & 0x1000) == 0x1000) { + $info = 'p'; // FIFO pipe + } else { + $info = 'u'; // Unknown + } - // Owner - $info .= (($perms & 0x0100) ? 'r' : '-'); - $info .= (($perms & 0x0080) ? 'w' : '-'); - $info .= (($perms & 0x0040) ? - (($perms & 0x0800) ? 's' : 'x' ) : - (($perms & 0x0800) ? 'S' : '-')); + // Owner + $info .= (($perms & 0x0100) ? 'r' : '-'); + $info .= (($perms & 0x0080) ? 'w' : '-'); + $info .= (($perms & 0x0040) ? + (($perms & 0x0800) ? 's' : 'x' ) : + (($perms & 0x0800) ? 'S' : '-')); - // Group - $info .= (($perms & 0x0020) ? 'r' : '-'); - $info .= (($perms & 0x0010) ? 'w' : '-'); - $info .= (($perms & 0x0008) ? - (($perms & 0x0400) ? 's' : 'x' ) : - (($perms & 0x0400) ? 'S' : '-')); + // Group + $info .= (($perms & 0x0020) ? 'r' : '-'); + $info .= (($perms & 0x0010) ? 'w' : '-'); + $info .= (($perms & 0x0008) ? + (($perms & 0x0400) ? 's' : 'x' ) : + (($perms & 0x0400) ? 'S' : '-')); - // World - $info .= (($perms & 0x0004) ? 'r' : '-'); - $info .= (($perms & 0x0002) ? 'w' : '-'); - $info .= (($perms & 0x0001) ? - (($perms & 0x0200) ? 't' : 'x' ) : - (($perms & 0x0200) ? 'T' : '-')); + // World + $info .= (($perms & 0x0004) ? 'r' : '-'); + $info .= (($perms & 0x0002) ? 'w' : '-'); + $info .= (($perms & 0x0001) ? + (($perms & 0x0200) ? 't' : 'x' ) : + (($perms & 0x0200) ? 'T' : '-')); - return '('.substr(sprintf('%o',$perms),-4).'/'.$info.')'; -} + return '('.substr(sprintf('%o',$perms),-4).'/'.$info.')'; + } -function main($args) { - $me = array_shift($args); - $ret = 0; - foreach ($args as $file) { - $data = stat($file); - if ($data === false) { - echo $me.': cannot stat file: `'.$file."'\n"; - $ret++; - } else { - echo ' File: `'.$file."'\n"; - echo ' Size: '.$data['size']."\t"; - echo 'Blocks: '.$data['blocks']."\t"; - //echo 'IO Block: '; - echo $data['rdev']."\n"; - echo 'Device: '.$data['dev']."\t"; - echo 'Inode: '.$data['ino']."\t"; - echo 'Links: '.$data['nlink']."\n"; - echo 'Access: '.perms($data['mode'])."\t"; - echo "\n"; + public static function main($args, $env) { + $me = array_shift($args); + $ret = 0; + foreach ($args as $file) { + $data = stat($file); + if ($data === false) { + echo $me.': cannot stat file: `'.$file."'\n"; + $ret++; + } else { + echo ' File: `'.$file."'\n"; + echo ' Size: '.$data['size']."\t"; + echo 'Blocks: '.$data['blocks']."\t"; + //echo 'IO Block: '; + echo $data['rdev']."\n"; + echo 'Device: '.$data['dev']."\t"; + echo 'Inode: '.$data['ino']."\t"; + echo 'Links: '.$data['nlink']."\n"; + echo 'Access: '.self::perms($data['mode'])."\t"; + echo "\n"; + } } + return $ret; } - return $ret; -}
\ No newline at end of file +} + |