1--TEST--
2stream_get_meta_data() with differing file access modes
3--FILE--
4<?php
5
6// array of all file access modes
7$filemodes = array('r', 'r+', 'w', 'w+', 'a', 'a+', 'x', 'x+',
8                   'rb', 'rb+', 'wb', 'wb+', 'ab', 'ab+', 'xb', 'xb+',
9                   'rt', 'rt+', 'wt', 'wt+', 'at', 'at+', 'xt', 'xt+');
10
11//create a file
12$filename = __FILE__ . '.tmp';
13$fp = fopen($filename, 'w+');
14fclose($fp);
15
16// open file in each access mode and get meta data
17foreach ($filemodes as $mode) {
18    if (strncmp($mode, 'x', 1) == 0) {
19        // x modes require that file does not exist
20        unlink($filename);
21    }
22    $fp = fopen($filename, $mode);
23    var_dump(stream_get_meta_data($fp));
24    fclose($fp);
25}
26
27unlink($filename);
28
29?>
30--EXPECTF--
31array(9) {
32  ["timed_out"]=>
33  bool(false)
34  ["blocked"]=>
35  bool(true)
36  ["eof"]=>
37  bool(false)
38  ["wrapper_type"]=>
39  string(9) "plainfile"
40  ["stream_type"]=>
41  string(5) "STDIO"
42  ["mode"]=>
43  string(1) "r"
44  ["unread_bytes"]=>
45  int(0)
46  ["seekable"]=>
47  bool(true)
48  ["uri"]=>
49  string(%i) "%s.tmp"
50}
51array(9) {
52  ["timed_out"]=>
53  bool(false)
54  ["blocked"]=>
55  bool(true)
56  ["eof"]=>
57  bool(false)
58  ["wrapper_type"]=>
59  string(9) "plainfile"
60  ["stream_type"]=>
61  string(5) "STDIO"
62  ["mode"]=>
63  string(2) "r+"
64  ["unread_bytes"]=>
65  int(0)
66  ["seekable"]=>
67  bool(true)
68  ["uri"]=>
69  string(%i) "%s.tmp"
70}
71array(9) {
72  ["timed_out"]=>
73  bool(false)
74  ["blocked"]=>
75  bool(true)
76  ["eof"]=>
77  bool(false)
78  ["wrapper_type"]=>
79  string(9) "plainfile"
80  ["stream_type"]=>
81  string(5) "STDIO"
82  ["mode"]=>
83  string(1) "w"
84  ["unread_bytes"]=>
85  int(0)
86  ["seekable"]=>
87  bool(true)
88  ["uri"]=>
89  string(%i) "%s.tmp"
90}
91array(9) {
92  ["timed_out"]=>
93  bool(false)
94  ["blocked"]=>
95  bool(true)
96  ["eof"]=>
97  bool(false)
98  ["wrapper_type"]=>
99  string(9) "plainfile"
100  ["stream_type"]=>
101  string(5) "STDIO"
102  ["mode"]=>
103  string(2) "w+"
104  ["unread_bytes"]=>
105  int(0)
106  ["seekable"]=>
107  bool(true)
108  ["uri"]=>
109  string(%i) "%s.tmp"
110}
111array(9) {
112  ["timed_out"]=>
113  bool(false)
114  ["blocked"]=>
115  bool(true)
116  ["eof"]=>
117  bool(false)
118  ["wrapper_type"]=>
119  string(9) "plainfile"
120  ["stream_type"]=>
121  string(5) "STDIO"
122  ["mode"]=>
123  string(1) "a"
124  ["unread_bytes"]=>
125  int(0)
126  ["seekable"]=>
127  bool(true)
128  ["uri"]=>
129  string(%i) "%s.tmp"
130}
131array(9) {
132  ["timed_out"]=>
133  bool(false)
134  ["blocked"]=>
135  bool(true)
136  ["eof"]=>
137  bool(false)
138  ["wrapper_type"]=>
139  string(9) "plainfile"
140  ["stream_type"]=>
141  string(5) "STDIO"
142  ["mode"]=>
143  string(2) "a+"
144  ["unread_bytes"]=>
145  int(0)
146  ["seekable"]=>
147  bool(true)
148  ["uri"]=>
149  string(%i) "%s.tmp"
150}
151array(9) {
152  ["timed_out"]=>
153  bool(false)
154  ["blocked"]=>
155  bool(true)
156  ["eof"]=>
157  bool(false)
158  ["wrapper_type"]=>
159  string(9) "plainfile"
160  ["stream_type"]=>
161  string(5) "STDIO"
162  ["mode"]=>
163  string(1) "x"
164  ["unread_bytes"]=>
165  int(0)
166  ["seekable"]=>
167  bool(true)
168  ["uri"]=>
169  string(%i) "%s.tmp"
170}
171array(9) {
172  ["timed_out"]=>
173  bool(false)
174  ["blocked"]=>
175  bool(true)
176  ["eof"]=>
177  bool(false)
178  ["wrapper_type"]=>
179  string(9) "plainfile"
180  ["stream_type"]=>
181  string(5) "STDIO"
182  ["mode"]=>
183  string(2) "x+"
184  ["unread_bytes"]=>
185  int(0)
186  ["seekable"]=>
187  bool(true)
188  ["uri"]=>
189  string(%i) "%s.tmp"
190}
191array(9) {
192  ["timed_out"]=>
193  bool(false)
194  ["blocked"]=>
195  bool(true)
196  ["eof"]=>
197  bool(false)
198  ["wrapper_type"]=>
199  string(9) "plainfile"
200  ["stream_type"]=>
201  string(5) "STDIO"
202  ["mode"]=>
203  string(2) "rb"
204  ["unread_bytes"]=>
205  int(0)
206  ["seekable"]=>
207  bool(true)
208  ["uri"]=>
209  string(%i) "%s.tmp"
210}
211array(9) {
212  ["timed_out"]=>
213  bool(false)
214  ["blocked"]=>
215  bool(true)
216  ["eof"]=>
217  bool(false)
218  ["wrapper_type"]=>
219  string(9) "plainfile"
220  ["stream_type"]=>
221  string(5) "STDIO"
222  ["mode"]=>
223  string(3) "rb+"
224  ["unread_bytes"]=>
225  int(0)
226  ["seekable"]=>
227  bool(true)
228  ["uri"]=>
229  string(%i) "%s.tmp"
230}
231array(9) {
232  ["timed_out"]=>
233  bool(false)
234  ["blocked"]=>
235  bool(true)
236  ["eof"]=>
237  bool(false)
238  ["wrapper_type"]=>
239  string(9) "plainfile"
240  ["stream_type"]=>
241  string(5) "STDIO"
242  ["mode"]=>
243  string(2) "wb"
244  ["unread_bytes"]=>
245  int(0)
246  ["seekable"]=>
247  bool(true)
248  ["uri"]=>
249  string(%i) "%s.tmp"
250}
251array(9) {
252  ["timed_out"]=>
253  bool(false)
254  ["blocked"]=>
255  bool(true)
256  ["eof"]=>
257  bool(false)
258  ["wrapper_type"]=>
259  string(9) "plainfile"
260  ["stream_type"]=>
261  string(5) "STDIO"
262  ["mode"]=>
263  string(3) "wb+"
264  ["unread_bytes"]=>
265  int(0)
266  ["seekable"]=>
267  bool(true)
268  ["uri"]=>
269  string(%i) "%s.tmp"
270}
271array(9) {
272  ["timed_out"]=>
273  bool(false)
274  ["blocked"]=>
275  bool(true)
276  ["eof"]=>
277  bool(false)
278  ["wrapper_type"]=>
279  string(9) "plainfile"
280  ["stream_type"]=>
281  string(5) "STDIO"
282  ["mode"]=>
283  string(2) "ab"
284  ["unread_bytes"]=>
285  int(0)
286  ["seekable"]=>
287  bool(true)
288  ["uri"]=>
289  string(%i) "%s.tmp"
290}
291array(9) {
292  ["timed_out"]=>
293  bool(false)
294  ["blocked"]=>
295  bool(true)
296  ["eof"]=>
297  bool(false)
298  ["wrapper_type"]=>
299  string(9) "plainfile"
300  ["stream_type"]=>
301  string(5) "STDIO"
302  ["mode"]=>
303  string(3) "ab+"
304  ["unread_bytes"]=>
305  int(0)
306  ["seekable"]=>
307  bool(true)
308  ["uri"]=>
309  string(%i) "%s.tmp"
310}
311array(9) {
312  ["timed_out"]=>
313  bool(false)
314  ["blocked"]=>
315  bool(true)
316  ["eof"]=>
317  bool(false)
318  ["wrapper_type"]=>
319  string(9) "plainfile"
320  ["stream_type"]=>
321  string(5) "STDIO"
322  ["mode"]=>
323  string(2) "xb"
324  ["unread_bytes"]=>
325  int(0)
326  ["seekable"]=>
327  bool(true)
328  ["uri"]=>
329  string(%i) "%s.tmp"
330}
331array(9) {
332  ["timed_out"]=>
333  bool(false)
334  ["blocked"]=>
335  bool(true)
336  ["eof"]=>
337  bool(false)
338  ["wrapper_type"]=>
339  string(9) "plainfile"
340  ["stream_type"]=>
341  string(5) "STDIO"
342  ["mode"]=>
343  string(3) "xb+"
344  ["unread_bytes"]=>
345  int(0)
346  ["seekable"]=>
347  bool(true)
348  ["uri"]=>
349  string(%i) "%s.tmp"
350}
351array(9) {
352  ["timed_out"]=>
353  bool(false)
354  ["blocked"]=>
355  bool(true)
356  ["eof"]=>
357  bool(false)
358  ["wrapper_type"]=>
359  string(9) "plainfile"
360  ["stream_type"]=>
361  string(5) "STDIO"
362  ["mode"]=>
363  string(2) "rt"
364  ["unread_bytes"]=>
365  int(0)
366  ["seekable"]=>
367  bool(true)
368  ["uri"]=>
369  string(%i) "%s.tmp"
370}
371array(9) {
372  ["timed_out"]=>
373  bool(false)
374  ["blocked"]=>
375  bool(true)
376  ["eof"]=>
377  bool(false)
378  ["wrapper_type"]=>
379  string(9) "plainfile"
380  ["stream_type"]=>
381  string(5) "STDIO"
382  ["mode"]=>
383  string(3) "rt+"
384  ["unread_bytes"]=>
385  int(0)
386  ["seekable"]=>
387  bool(true)
388  ["uri"]=>
389  string(%i) "%s.tmp"
390}
391array(9) {
392  ["timed_out"]=>
393  bool(false)
394  ["blocked"]=>
395  bool(true)
396  ["eof"]=>
397  bool(false)
398  ["wrapper_type"]=>
399  string(9) "plainfile"
400  ["stream_type"]=>
401  string(5) "STDIO"
402  ["mode"]=>
403  string(2) "wt"
404  ["unread_bytes"]=>
405  int(0)
406  ["seekable"]=>
407  bool(true)
408  ["uri"]=>
409  string(%i) "%s.tmp"
410}
411array(9) {
412  ["timed_out"]=>
413  bool(false)
414  ["blocked"]=>
415  bool(true)
416  ["eof"]=>
417  bool(false)
418  ["wrapper_type"]=>
419  string(9) "plainfile"
420  ["stream_type"]=>
421  string(5) "STDIO"
422  ["mode"]=>
423  string(3) "wt+"
424  ["unread_bytes"]=>
425  int(0)
426  ["seekable"]=>
427  bool(true)
428  ["uri"]=>
429  string(%i) "%s.tmp"
430}
431array(9) {
432  ["timed_out"]=>
433  bool(false)
434  ["blocked"]=>
435  bool(true)
436  ["eof"]=>
437  bool(false)
438  ["wrapper_type"]=>
439  string(9) "plainfile"
440  ["stream_type"]=>
441  string(5) "STDIO"
442  ["mode"]=>
443  string(2) "at"
444  ["unread_bytes"]=>
445  int(0)
446  ["seekable"]=>
447  bool(true)
448  ["uri"]=>
449  string(%i) "%s.tmp"
450}
451array(9) {
452  ["timed_out"]=>
453  bool(false)
454  ["blocked"]=>
455  bool(true)
456  ["eof"]=>
457  bool(false)
458  ["wrapper_type"]=>
459  string(9) "plainfile"
460  ["stream_type"]=>
461  string(5) "STDIO"
462  ["mode"]=>
463  string(3) "at+"
464  ["unread_bytes"]=>
465  int(0)
466  ["seekable"]=>
467  bool(true)
468  ["uri"]=>
469  string(%i) "%s.tmp"
470}
471array(9) {
472  ["timed_out"]=>
473  bool(false)
474  ["blocked"]=>
475  bool(true)
476  ["eof"]=>
477  bool(false)
478  ["wrapper_type"]=>
479  string(9) "plainfile"
480  ["stream_type"]=>
481  string(5) "STDIO"
482  ["mode"]=>
483  string(2) "xt"
484  ["unread_bytes"]=>
485  int(0)
486  ["seekable"]=>
487  bool(true)
488  ["uri"]=>
489  string(%i) "%s.tmp"
490}
491array(9) {
492  ["timed_out"]=>
493  bool(false)
494  ["blocked"]=>
495  bool(true)
496  ["eof"]=>
497  bool(false)
498  ["wrapper_type"]=>
499  string(9) "plainfile"
500  ["stream_type"]=>
501  string(5) "STDIO"
502  ["mode"]=>
503  string(3) "xt+"
504  ["unread_bytes"]=>
505  int(0)
506  ["seekable"]=>
507  bool(true)
508  ["uri"]=>
509  string(%i) "%s.tmp"
510}
511