blob: e2f9f5b84c24ed213ebd5663da57e44ba76dbadf (
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
|
--TEST--
Testing fseek() on a directory stream
--FILE--
<?php
// include the file.inc for Function: function create_files()
require(__DIR__ . '/file.inc');
$path = __DIR__ . '/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(%d) 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)
|