/4.0/Testing/Tests/FileSystem/stat.php
PHP | 59 lines | 45 code | 10 blank | 4 comment | 3 complexity | 1e39dbc8a67be298cad9faf284458136 MD5 | raw file
Possible License(s): CPL-1.0, GPL-2.0, CC-BY-SA-3.0, MPL-2.0-no-copyleft-exception, Apache-2.0
- [comment] We have different mtime and ctime sometimes... Not tested for output, just for compiling and running.
-
- [file]
-
- <pre>
- <?php
- function folder($folder)
- {
- unset($rv);
- $handle = opendir($folder);
- while (false !== ($file = readdir($handle)))
- {
- $rv[] = $folder.$file;
- }
- closedir($handle);
- sort($rv);
- return $rv;
- }
-
- $statfields = array(
- "dev",
- "ino",
- //"mode", // Directory w sometimes not set - why?
- "uid",
- "gid",
- "rdev",
- "size",
- //"atime", // Minor difference - why?
- "mtime",
- "ctime",
- "blksize",
- "blocks"
- );
-
- function getstat($f)
- {
- global $statfields;
-
- $a = stat($f);
- $rv = "!!$f";
-
- foreach ($statfields as $key)
- $rv .= "\n $key => " . $a[$key];
-
- // $rv .= "\n MODE => " . decbin($a['mode']);
-
- return $rv;
- }
-
- function printdir($a, $n)
- {
- echo "<hr><p>" . realpath($n) . "\n";
- foreach ($a as $k => $v) echo " [$k] => stat($v)\n (" .getstat($v). "\n )\n";
- }
-
- printdir(folder("C:\\"), "C:\\");
- //printdir(folder("./"), "./");
- ?>
- </pre>