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