readdir_variation2-win32-mb.phpt 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --TEST--
  2. Test readdir() function : usage variations - empty directories
  3. --SKIPIF--
  4. <?php
  5. if (substr(PHP_OS, 0, 3) != 'WIN') {
  6. die("skip Valid only on Windows");
  7. }
  8. ?>
  9. --FILE--
  10. <?php
  11. /*
  12. * Pass readdir() a directory handle pointing to an empty directory to test behaviour
  13. */
  14. echo "*** Testing readdir() : usage variations ***\n";
  15. $path = __DIR__ . '/私はガラスを食べられますreaddir_variation2';
  16. mkdir($path);
  17. $dir_handle = opendir($path);
  18. echo "\n-- Pass an empty directory to readdir() --\n";
  19. function mysort($a,$b) {
  20. return strlen($a) > strlen($b) ? 1 : -1;
  21. }
  22. $entries = array();
  23. while(FALSE !== ($file = readdir($dir_handle))){
  24. $entries[] = $file;
  25. }
  26. closedir($dir_handle);
  27. usort($entries, "mysort");
  28. foreach($entries as $entry) {
  29. var_dump($entry);
  30. }
  31. ?>
  32. --CLEAN--
  33. <?php
  34. $path = __DIR__ . '/私はガラスを食べられますreaddir_variation2';
  35. rmdir($path);
  36. ?>
  37. --EXPECT--
  38. *** Testing readdir() : usage variations ***
  39. -- Pass an empty directory to readdir() --
  40. string(1) "."
  41. string(2) ".."