Annotation of embedaddon/php/ext/standard/tests/file/fseek_dir_basic.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Testing fseek() on a directory stream
3: --FILE--
4: <?php
5:
6: // include the file.inc for Function: function create_files()
7: require(dirname(__FILE__) . '/file.inc');
8:
9: $path = dirname(__FILE__) . '/fseek_dir_basic';
10: mkdir($path);
11: create_files($path, 3);
12:
13: echo "call readdir():\n";
14: var_dump($dh = opendir($path));
15: $files = array();
16: while( FALSE !== ($files[] = readdir($dh)) ) {}
17: sort($files);
18: var_dump($files);
19: $files = array();
20:
21: echo "\ncall fseek() on directory resource:\n";
22: var_dump(fseek($dh, 20));
23:
24: echo "call readdir():\n";
25: while( FALSE !== ($files[] = readdir($dh)) ) {}
26: sort($files);
27: var_dump($files);
28: $files = array();
29:
30: echo "\ncall fseek() with different arguments on directory resource:\n";
31: var_dump(fseek($dh, 20, SEEK_END));
32:
33: echo "call readdir():\n";
34: while( FALSE !== ($files[] = readdir($dh)) ) {}
35: sort($files);
36: var_dump($files);
37:
38: delete_files($path, 3);
39: closedir($dh);
40: var_dump(rmdir($path));
41:
42: ?>
43: --EXPECTF--
44: call readdir():
45: resource(%d) of type (stream)
46: array(6) {
47: [0]=>
48: bool(false)
49: [1]=>
50: string(1) "."
51: [2]=>
52: string(2) ".."
53: [3]=>
54: string(9) "file1.tmp"
55: [4]=>
56: string(9) "file2.tmp"
57: [5]=>
58: string(9) "file3.tmp"
59: }
60:
61: call fseek() on directory resource:
62: int(0)
63: call readdir():
64: array(6) {
65: [0]=>
66: bool(false)
67: [1]=>
68: string(1) "."
69: [2]=>
70: string(2) ".."
71: [3]=>
72: string(9) "file1.tmp"
73: [4]=>
74: string(9) "file2.tmp"
75: [5]=>
76: string(9) "file3.tmp"
77: }
78:
79: call fseek() with different arguments on directory resource:
80: int(0)
81: call readdir():
82: array(6) {
83: [0]=>
84: bool(false)
85: [1]=>
86: string(1) "."
87: [2]=>
88: string(2) ".."
89: [3]=>
90: string(9) "file1.tmp"
91: [4]=>
92: string(9) "file2.tmp"
93: [5]=>
94: string(9) "file3.tmp"
95: }
96: bool(true)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>