xref: /PHP-8.1/ext/phar/tests/022.phpt (revision 74859783)
1--TEST--
2Phar: stream stat
3--EXTENSIONS--
4phar
5--INI--
6phar.require_hash=0
7--FILE--
8<?php
9$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.php';
10$pname = 'phar://' . $fname;
11$file = "<?php
12Phar::mapPhar('hio');
13__HALT_COMPILER(); ?>";
14
15$files = array();
16$files['a'] = 'abcdefg';
17
18include 'files/phar_test.inc';
19
20include $fname;
21
22$fp = fopen('phar://hio/a', 'r');
23var_dump(ftell($fp));
24echo 'fseek($fp, 1)';var_dump(fseek($fp, 1));
25var_dump(ftell($fp));
26echo 'fseek($fp, 1, SEEK_CUR)';var_dump(fseek($fp, 1, SEEK_CUR));
27var_dump(ftell($fp));
28echo 'fseek($fp, -1, SEEK_CUR)';var_dump(fseek($fp, -1, SEEK_CUR));
29var_dump(ftell($fp));
30echo 'fseek($fp, -1, SEEK_END)';var_dump(fseek($fp, -1, SEEK_END));
31var_dump(ftell($fp));
32echo 'fseek($fp, -8, SEEK_END)';var_dump(fseek($fp, -8, SEEK_END));
33var_dump(ftell($fp));
34echo 'fseek($fp, -7, SEEK_END)';var_dump(fseek($fp, -7, SEEK_END));
35var_dump(ftell($fp));
36echo 'fseek($fp, 0, SEEK_END)';var_dump(fseek($fp, 0, SEEK_END));
37var_dump(ftell($fp));
38echo 'fseek($fp, 1, SEEK_END)';var_dump(fseek($fp, 1, SEEK_END));
39var_dump(ftell($fp));
40echo 'fseek($fp, -8, SEEK_END)';var_dump(fseek($fp, -8, SEEK_END));
41var_dump(ftell($fp));
42echo 'fseek($fp, 6)';var_dump(fseek($fp, 6));
43var_dump(ftell($fp));
44echo 'fseek($fp, 8)';var_dump(fseek($fp, 8));
45var_dump(ftell($fp));
46echo 'fseek($fp, -1)';var_dump(fseek($fp, -1));
47var_dump(ftell($fp));
48echo "next\n";
49fseek($fp, 4);
50var_dump(ftell($fp));
51echo 'fseek($fp, -5, SEEK_CUR)';var_dump(fseek($fp, -5, SEEK_CUR));
52var_dump(ftell($fp));
53fseek($fp, 4);
54var_dump(ftell($fp));
55echo 'fseek($fp, 5, SEEK_CUR)';var_dump(fseek($fp, 5, SEEK_CUR));
56var_dump(ftell($fp));
57fseek($fp, 4);
58var_dump(ftell($fp));
59echo 'fseek($fp, -4, SEEK_CUR)';var_dump(fseek($fp, -4, SEEK_CUR));
60var_dump(ftell($fp));
61fseek($fp, 4);
62var_dump(ftell($fp));
63echo 'fseek($fp, 3, SEEK_CUR)';var_dump(fseek($fp, 3, SEEK_CUR));
64var_dump(ftell($fp));
65fclose($fp);
66?>
67--CLEAN--
68<?php
69unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
70exit(0);
71 ?>
72--EXPECT--
73int(0)
74fseek($fp, 1)int(0)
75int(1)
76fseek($fp, 1, SEEK_CUR)int(0)
77int(2)
78fseek($fp, -1, SEEK_CUR)int(0)
79int(1)
80fseek($fp, -1, SEEK_END)int(0)
81int(6)
82fseek($fp, -8, SEEK_END)int(-1)
83bool(false)
84fseek($fp, -7, SEEK_END)int(0)
85int(0)
86fseek($fp, 0, SEEK_END)int(0)
87int(7)
88fseek($fp, 1, SEEK_END)int(-1)
89bool(false)
90fseek($fp, -8, SEEK_END)int(-1)
91bool(false)
92fseek($fp, 6)int(0)
93int(6)
94fseek($fp, 8)int(-1)
95bool(false)
96fseek($fp, -1)int(-1)
97bool(false)
98next
99int(4)
100fseek($fp, -5, SEEK_CUR)int(-1)
101bool(false)
102int(4)
103fseek($fp, 5, SEEK_CUR)int(-1)
104bool(false)
105int(4)
106fseek($fp, -4, SEEK_CUR)int(0)
107int(0)
108int(4)
109fseek($fp, 3, SEEK_CUR)int(0)
110int(7)
111