blob: 6670917f3e8be09c45c5517b7a12013353c5c6ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
--TEST--
Testing fseek() on a directory stream
--FILE--
<?php
// include the file.inc for Function: function create_files()
require(dirname(__FILE__) . '/file.inc');
$path = dirname(__FILE__) . '/fseek_dir_basic';
mkdir($path);
create_files($path, 3);
echo "call readdir():\n";
var_dump($dh = opendir($path));
$files = array();
while( FALSE !== ($files[] = readdir($dh)) ) {}
sort($files);
var_dump($files);
$files = array();
echo "\ncall fseek() on directory resource:\n";
var_dump(fseek($dh, 20));
echo "call readdir():\n";
while( FALSE !== ($files[] = readdir($dh)) ) {}
sort($files);
var_dump($files);
$files = array();
echo "\ncall fseek() with different arguments on directory resource:\n";
var_dump(fseek($dh, 20, SEEK_END));
echo "call readdir():\n";
while( FALSE !== ($files[] = readdir($dh)) ) {}
sort($files);
var_dump($files);
delete_files($path, 3);
closedir($dh);
var_dump(rmdir($path));
?>
--EXPECTF--
call readdir():
resource(12) of type (stream)
array(6) {
[0]=>
bool(false)
[1]=>
string(1) "."
[2]=>
string(2) ".."
[3]=>
string(9) "file1.tmp"
[4]=>
string(9) "file2.tmp"
[5]=>
string(9) "file3.tmp"
}
call fseek() on directory resource:
int(0)
call readdir():
array(6) {
[0]=>
bool(false)
[1]=>
string(1) "."
[2]=>
string(2) ".."
[3]=>
string(9) "file1.tmp"
[4]=>
string(9) "file2.tmp"
[5]=>
string(9) "file3.tmp"
}
call fseek() with different arguments on directory resource:
int(0)
call readdir():
array(6) {
[0]=>
bool(false)
[1]=>
string(1) "."
[2]=>
string(2) ".."
[3]=>
string(9) "file1.tmp"
[4]=>
string(9) "file2.tmp"
[5]=>
string(9) "file3.tmp"
}
bool(true)
--UEXPECTF--
call readdir():
resource(12) of type (stream)
array(6) {
[0]=>
bool(false)
[1]=>
unicode(1) "."
[2]=>
unicode(2) ".."
[3]=>
unicode(9) "file1.tmp"
[4]=>
unicode(9) "file2.tmp"
[5]=>
unicode(9) "file3.tmp"
}
call fseek() on directory resource:
int(0)
call readdir():
array(6) {
[0]=>
bool(false)
[1]=>
unicode(1) "."
[2]=>
unicode(2) ".."
[3]=>
unicode(9) "file1.tmp"
[4]=>
unicode(9) "file2.tmp"
[5]=>
unicode(9) "file3.tmp"
}
call fseek() with different arguments on directory resource:
int(0)
call readdir():
array(6) {
[0]=>
bool(false)
[1]=>
unicode(1) "."
[2]=>
unicode(2) ".."
[3]=>
unicode(9) "file1.tmp"
[4]=>
unicode(9) "file2.tmp"
[5]=>
unicode(9) "file3.tmp"
}
bool(true)
|