summaryrefslogtreecommitdiff
path: root/ext/phar/tests/stat.phpt
blob: a3c8491aeea7b6f30a0ff2d5bd2ab0498df58860 (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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
--TEST--
Phar: test stat function interceptions
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip");?>
--INI--
phar.require_hash=1
phar.readonly=0
detect_unicode=0
--FILE--
<?php
Phar::interceptFileFuncs();
var_dump(stat(""));

$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.tar';
$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
$a = new Phar($fname);
$a['my/index.php'] = '<?php
echo "stat\n";
var_dump(stat("dir/file1.txt"));
echo "lstat\n";
var_dump(lstat("dir/file1.txt"));
echo "fileperms\n";
var_dump(fileperms("dir/file1.txt"));
echo "fileinode\n";
var_dump(fileinode("dir/file1.txt"));
echo "filesize\n";
var_dump(filesize("dir/file1.txt"));
echo "fileowner\n";
var_dump(fileowner("dir/file1.txt"));
echo "filegroup\n";
var_dump(filegroup("dir/file1.txt"));
echo "filemtime\n";
var_dump(filemtime("dir/file1.txt"));
echo "fileatime\n";
var_dump(fileatime("dir/file1.txt"));
echo "filectime\n";
var_dump(filectime("dir/file1.txt"));
echo "filetype\n";
var_dump(filetype("dir/file1.txt"));
echo "is_writable\n";
var_dump(is_writable("dir/file1.txt"));
echo "is_writeable\n";
var_dump(is_writeable("dir/file1.txt"));
echo "is_readable\n";
var_dump(is_readable("dir/file1.txt"));
echo "is_executable\n";
var_dump(is_executable("dir/file1.txt"));
echo "file_exists\n";
var_dump(file_exists("dir/file1.txt"));
echo "is_dir\n";
var_dump(is_dir("dir/file1.txt"));
echo "is_file\n";
var_dump(is_file("dir/file1.txt"));
echo "is_link\n";
var_dump(is_link("dir/file1.txt"));
echo "not found\n";
var_dump(file_exists("not/found"));
echo "not found 2\n";
var_dump(fileperms("not/found"));
?>';
$a['dir/file1.txt'] = 'hi';
$a['dir/file2.txt'] = 'hi2';
$a['dir/file3.txt'] = 'hi3';
$a->setStub('<?php
set_include_path("phar://" . __FILE__ . "/dir" . PATH_SEPARATOR . "phar://" . __FILE__);
include "my/index.php";
__HALT_COMPILER();');
include $fname;
?>
===DONE===
--CLEAN--
<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
--EXPECTF--
bool(false)
stat
array(26) {
  [0]=>
  int(12)
  [1]=>
  int(%d)
  [2]=>
  int(33206)
  [3]=>
  int(1)
  [4]=>
  int(0)
  [5]=>
  int(0)
  [6]=>
  int(%s)
  [7]=>
  int(2)
  [8]=>
  int(%d)
  [9]=>
  int(%d)
  [10]=>
  int(%d)
  [11]=>
  int(%s)
  [12]=>
  int(%s)
  ["dev"]=>
  int(12)
  ["ino"]=>
  int(%d)
  ["mode"]=>
  int(33206)
  ["nlink"]=>
  int(1)
  ["uid"]=>
  int(0)
  ["gid"]=>
  int(0)
  ["rdev"]=>
  int(%s)
  ["size"]=>
  int(2)
  ["atime"]=>
  int(%d)
  ["mtime"]=>
  int(%d)
  ["ctime"]=>
  int(%d)
  ["blksize"]=>
  int(%s)
  ["blocks"]=>
  int(%s)
}
lstat
array(26) {
  [0]=>
  int(12)
  [1]=>
  int(%d)
  [2]=>
  int(33206)
  [3]=>
  int(1)
  [4]=>
  int(0)
  [5]=>
  int(0)
  [6]=>
  int(%s)
  [7]=>
  int(2)
  [8]=>
  int(%d)
  [9]=>
  int(%d)
  [10]=>
  int(%d)
  [11]=>
  int(%s)
  [12]=>
  int(%s)
  ["dev"]=>
  int(12)
  ["ino"]=>
  int(%d)
  ["mode"]=>
  int(33206)
  ["nlink"]=>
  int(1)
  ["uid"]=>
  int(0)
  ["gid"]=>
  int(0)
  ["rdev"]=>
  int(%s)
  ["size"]=>
  int(2)
  ["atime"]=>
  int(%d)
  ["mtime"]=>
  int(%d)
  ["ctime"]=>
  int(%d)
  ["blksize"]=>
  int(%s)
  ["blocks"]=>
  int(%s)
}
fileperms
int(33206)
fileinode
int(%d)
filesize
int(2)
fileowner
int(0)
filegroup
int(0)
filemtime
int(%d)
fileatime
int(%d)
filectime
int(%d)
filetype
string(4) "file"
is_writable
bool(true)
is_writeable
bool(false)
is_readable
bool(true)
is_executable
bool(false)
file_exists
bool(true)
is_dir
bool(false)
is_file
bool(true)
is_link
bool(false)
not found
bool(false)
not found 2

Warning: fileperms(): stat failed for not/found in phar://%sstat.phar.php/my/index.php on line %d
bool(false)
===DONE===