1--TEST--
2Test readdir() function : usage variations - operate on previously opened directory
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) != 'WIN') {
6  die("skip Valid only on Windows");
7}
8?>
9--FILE--
10<?php
11/* Prototype  : string readdir([resource $dir_handle])
12 * Description: Read directory entry from dir_handle
13 * Source code: ext/standard/dir.c
14 */
15
16/*
17 * Open two directory handles on the same directory and pass both
18 * to readdir() to test behaviour
19 */
20
21echo "*** Testing readdir() : usage variations ***\n";
22
23// include the file.inc for Function: function create_files()
24include( dirname(__FILE__)."/../file/file.inc");
25
26// create the temporary directory
27$dir_path = dirname(__FILE__) . "/私はガラスを食べられますreaddir_variation6";
28mkdir($dir_path);
29
30// create files within the temporary directory
31create_files($dir_path, 3, "alphanumeric", 0755, 1, "w", "私はガラスを食べられますreaddir_variation6");
32
33// open the directory
34$dir_handle1 = opendir($dir_path);
35
36// open the same directory again without closing it
37opendir($dir_path);
38
39echo "\n-- Reading Directory Contents with Previous Handle --\n";
40$a = array();
41while (FALSE !== ($file = readdir($dir_handle1))) {
42	$a[] = $file;
43}
44sort($a);
45foreach ($a as $file) {
46	var_dump($file);
47}
48
49echo "\n-- Reading Directory Contents with Current Handle (no arguments supplied) --\n";
50$a = array();
51while (FALSE !== ($file = readdir())) {
52	$a[] = $file;
53}
54sort($a);
55foreach ($a as $file) {
56	var_dump($file);
57}
58
59// delete temporary files
60delete_files($dir_path, 3, "私はガラスを食べられますreaddir_variation6");
61closedir($dir_handle1);
62closedir();
63?>
64===DONE===
65--CLEAN--
66<?php
67$dir_path = dirname(__FILE__) . "/私はガラスを食べられますreaddir_variation6";
68rmdir($dir_path);
69?>
70--EXPECTF--
71*** Testing readdir() : usage variations ***
72
73-- Reading Directory Contents with Previous Handle --
74string(1) "."
75string(2) ".."
76string(59) "私はガラスを食べられますreaddir_variation61.tmp"
77string(59) "私はガラスを食べられますreaddir_variation62.tmp"
78string(59) "私はガラスを食べられますreaddir_variation63.tmp"
79
80-- Reading Directory Contents with Current Handle (no arguments supplied) --
81string(1) "."
82string(2) ".."
83string(59) "私はガラスを食べられますreaddir_variation61.tmp"
84string(59) "私はガラスを食べられますreaddir_variation62.tmp"
85string(59) "私はガラスを食べられますreaddir_variation63.tmp"
86===DONE===
87