PageRenderTime 46ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  1. [comment] We have different mtime and ctime sometimes... Not tested for output, just for compiling and running.
  2. [file]
  3. <pre>
  4. <?php
  5. function folder($folder)
  6. {
  7. unset($rv);
  8. $handle = opendir($folder);
  9. while (false !== ($file = readdir($handle)))
  10. {
  11. $rv[] = $folder.$file;
  12. }
  13. closedir($handle);
  14. sort($rv);
  15. return $rv;
  16. }
  17. $statfields = array(
  18. "dev",
  19. "ino",
  20. //"mode", // Directory w sometimes not set - why?
  21. "uid",
  22. "gid",
  23. "rdev",
  24. "size",
  25. //"atime", // Minor difference - why?
  26. "mtime",
  27. "ctime",
  28. "blksize",
  29. "blocks"
  30. );
  31. function getstat($f)
  32. {
  33. global $statfields;
  34. $a = stat($f);
  35. $rv = "!!$f";
  36. foreach ($statfields as $key)
  37. $rv .= "\n $key => " . $a[$key];
  38. // $rv .= "\n MODE => " . decbin($a['mode']);
  39. return $rv;
  40. }
  41. function printdir($a, $n)
  42. {
  43. echo "<hr><p>" . realpath($n) . "\n";
  44. foreach ($a as $k => $v) echo " [$k] => stat($v)\n (" .getstat($v). "\n )\n";
  45. }
  46. printdir(folder("C:\\"), "C:\\");
  47. //printdir(folder("./"), "./");
  48. ?>
  49. </pre>