Annotation of embedaddon/php/ext/standard/tests/file/fseek_ftell_rewind_variation8.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test fseek(), ftell() & rewind() functions : usage variations - all w and x modes, SEEK_END
3: --SKIPIF--
4: <?php
5: if( substr(PHP_OS, 0, 3) == "WIN" )
6: die("skip.. Not valid for Windows");
7: ?>
8: --FILE--
9: <?php
10: /* Prototype: int fseek ( resource $handle, int $offset [, int $whence] );
11: Description: Seeks on a file pointer
12:
13: Prototype: bool rewind ( resource $handle );
14: Description: Rewind the position of a file pointer
15:
16: Prototype: int ftell ( resource $handle );
17: Description: Tells file pointer read/write position
18: */
19:
20: // include the file.inc for common functions for test
21: include ("file.inc");
22:
23: /* Testing fseek(),ftell(),rewind() functions
24: 1. All write and create with write modes
25: 2. Testing fseek() with whence = SEEK_END
26: */
27: echo "*** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes ***\n";
28:
29: $file_modes = array( "w","wb","wt","w+","w+b","w+t",
30: "x","xb","xt","x+","x+b","x+t");
31: $file_content_types = array( "text_with_new_line","alphanumeric");
32:
33: $offset = array(-1,0,1,512,600); // different offsets
34:
35: $filename = dirname(__FILE__)."/fseek_ftell_rewind_variation8.tmp"; // this is name of the file created by create_files()
36:
37: /* open the file using $files_modes and perform fseek(),ftell() and rewind() on it */
38: foreach($file_content_types as $file_content_type){
39: echo "\n-- File having data of type ". $file_content_type ." --\n";
40:
41: foreach($file_modes as $file_mode) {
42: echo "-- File opened in mode ".$file_mode." --\n";
43: $file_handle = fopen($filename, $file_mode);
44: if (!$file_handle){
45: echo "Error: failed to fopen() file: $filename!";
46: exit();
47: }
48: $data_to_be_written="";
49: fill_buffer($data_to_be_written, $file_content_type, 512); //get the data of size 512
50: $data_to_be_written = $data_to_be_written;
51: fwrite($file_handle,(binary)$data_to_be_written);
52: rewind($file_handle);
53:
54: foreach($offset as $count){
55: var_dump( fseek($file_handle,$count,SEEK_END) );
56: var_dump( ftell($file_handle) ); // confirm the file pointer position
57: var_dump( feof($file_handle) ); //ensure that file pointer is not at end
58: } //end of offset loop
59:
60: //close the file and check the size
61: fclose($file_handle);
62: var_dump( filesize($filename) );
63:
64: delete_file($filename); // delete file with name
65: } //end of file_mode loop
66: } //end of file_content_types loop
67:
68: echo "Done\n";
69: ?>
70: --EXPECTF--
71: *** Testing fseek(), ftell(), rewind() : whence = SEEK_END & all r and a modes ***
72:
73: -- File having data of type text_with_new_line --
74: -- File opened in mode w --
75: int(0)
76: int(511)
77: bool(false)
78: int(0)
79: int(512)
80: bool(false)
81: int(0)
82: int(513)
83: bool(false)
84: int(0)
85: int(1024)
86: bool(false)
87: int(0)
88: int(1112)
89: bool(false)
90: int(512)
91: -- File opened in mode wb --
92: int(0)
93: int(511)
94: bool(false)
95: int(0)
96: int(512)
97: bool(false)
98: int(0)
99: int(513)
100: bool(false)
101: int(0)
102: int(1024)
103: bool(false)
104: int(0)
105: int(1112)
106: bool(false)
107: int(512)
108: -- File opened in mode wt --
109: int(0)
110: int(511)
111: bool(false)
112: int(0)
113: int(512)
114: bool(false)
115: int(0)
116: int(513)
117: bool(false)
118: int(0)
119: int(1024)
120: bool(false)
121: int(0)
122: int(1112)
123: bool(false)
124: int(512)
125: -- File opened in mode w+ --
126: int(0)
127: int(511)
128: bool(false)
129: int(0)
130: int(512)
131: bool(false)
132: int(0)
133: int(513)
134: bool(false)
135: int(0)
136: int(1024)
137: bool(false)
138: int(0)
139: int(1112)
140: bool(false)
141: int(512)
142: -- File opened in mode w+b --
143: int(0)
144: int(511)
145: bool(false)
146: int(0)
147: int(512)
148: bool(false)
149: int(0)
150: int(513)
151: bool(false)
152: int(0)
153: int(1024)
154: bool(false)
155: int(0)
156: int(1112)
157: bool(false)
158: int(512)
159: -- File opened in mode w+t --
160: int(0)
161: int(511)
162: bool(false)
163: int(0)
164: int(512)
165: bool(false)
166: int(0)
167: int(513)
168: bool(false)
169: int(0)
170: int(1024)
171: bool(false)
172: int(0)
173: int(1112)
174: bool(false)
175: int(512)
176: -- File opened in mode x --
177: int(0)
178: int(511)
179: bool(false)
180: int(0)
181: int(512)
182: bool(false)
183: int(0)
184: int(513)
185: bool(false)
186: int(0)
187: int(1024)
188: bool(false)
189: int(0)
190: int(1112)
191: bool(false)
192: int(512)
193: -- File opened in mode xb --
194: int(0)
195: int(511)
196: bool(false)
197: int(0)
198: int(512)
199: bool(false)
200: int(0)
201: int(513)
202: bool(false)
203: int(0)
204: int(1024)
205: bool(false)
206: int(0)
207: int(1112)
208: bool(false)
209: int(512)
210: -- File opened in mode xt --
211: int(0)
212: int(511)
213: bool(false)
214: int(0)
215: int(512)
216: bool(false)
217: int(0)
218: int(513)
219: bool(false)
220: int(0)
221: int(1024)
222: bool(false)
223: int(0)
224: int(1112)
225: bool(false)
226: int(512)
227: -- File opened in mode x+ --
228: int(0)
229: int(511)
230: bool(false)
231: int(0)
232: int(512)
233: bool(false)
234: int(0)
235: int(513)
236: bool(false)
237: int(0)
238: int(1024)
239: bool(false)
240: int(0)
241: int(1112)
242: bool(false)
243: int(512)
244: -- File opened in mode x+b --
245: int(0)
246: int(511)
247: bool(false)
248: int(0)
249: int(512)
250: bool(false)
251: int(0)
252: int(513)
253: bool(false)
254: int(0)
255: int(1024)
256: bool(false)
257: int(0)
258: int(1112)
259: bool(false)
260: int(512)
261: -- File opened in mode x+t --
262: int(0)
263: int(511)
264: bool(false)
265: int(0)
266: int(512)
267: bool(false)
268: int(0)
269: int(513)
270: bool(false)
271: int(0)
272: int(1024)
273: bool(false)
274: int(0)
275: int(1112)
276: bool(false)
277: int(512)
278:
279: -- File having data of type alphanumeric --
280: -- File opened in mode w --
281: int(0)
282: int(511)
283: bool(false)
284: int(0)
285: int(512)
286: bool(false)
287: int(0)
288: int(513)
289: bool(false)
290: int(0)
291: int(1024)
292: bool(false)
293: int(0)
294: int(1112)
295: bool(false)
296: int(512)
297: -- File opened in mode wb --
298: int(0)
299: int(511)
300: bool(false)
301: int(0)
302: int(512)
303: bool(false)
304: int(0)
305: int(513)
306: bool(false)
307: int(0)
308: int(1024)
309: bool(false)
310: int(0)
311: int(1112)
312: bool(false)
313: int(512)
314: -- File opened in mode wt --
315: int(0)
316: int(511)
317: bool(false)
318: int(0)
319: int(512)
320: bool(false)
321: int(0)
322: int(513)
323: bool(false)
324: int(0)
325: int(1024)
326: bool(false)
327: int(0)
328: int(1112)
329: bool(false)
330: int(512)
331: -- File opened in mode w+ --
332: int(0)
333: int(511)
334: bool(false)
335: int(0)
336: int(512)
337: bool(false)
338: int(0)
339: int(513)
340: bool(false)
341: int(0)
342: int(1024)
343: bool(false)
344: int(0)
345: int(1112)
346: bool(false)
347: int(512)
348: -- File opened in mode w+b --
349: int(0)
350: int(511)
351: bool(false)
352: int(0)
353: int(512)
354: bool(false)
355: int(0)
356: int(513)
357: bool(false)
358: int(0)
359: int(1024)
360: bool(false)
361: int(0)
362: int(1112)
363: bool(false)
364: int(512)
365: -- File opened in mode w+t --
366: int(0)
367: int(511)
368: bool(false)
369: int(0)
370: int(512)
371: bool(false)
372: int(0)
373: int(513)
374: bool(false)
375: int(0)
376: int(1024)
377: bool(false)
378: int(0)
379: int(1112)
380: bool(false)
381: int(512)
382: -- File opened in mode x --
383: int(0)
384: int(511)
385: bool(false)
386: int(0)
387: int(512)
388: bool(false)
389: int(0)
390: int(513)
391: bool(false)
392: int(0)
393: int(1024)
394: bool(false)
395: int(0)
396: int(1112)
397: bool(false)
398: int(512)
399: -- File opened in mode xb --
400: int(0)
401: int(511)
402: bool(false)
403: int(0)
404: int(512)
405: bool(false)
406: int(0)
407: int(513)
408: bool(false)
409: int(0)
410: int(1024)
411: bool(false)
412: int(0)
413: int(1112)
414: bool(false)
415: int(512)
416: -- File opened in mode xt --
417: int(0)
418: int(511)
419: bool(false)
420: int(0)
421: int(512)
422: bool(false)
423: int(0)
424: int(513)
425: bool(false)
426: int(0)
427: int(1024)
428: bool(false)
429: int(0)
430: int(1112)
431: bool(false)
432: int(512)
433: -- File opened in mode x+ --
434: int(0)
435: int(511)
436: bool(false)
437: int(0)
438: int(512)
439: bool(false)
440: int(0)
441: int(513)
442: bool(false)
443: int(0)
444: int(1024)
445: bool(false)
446: int(0)
447: int(1112)
448: bool(false)
449: int(512)
450: -- File opened in mode x+b --
451: int(0)
452: int(511)
453: bool(false)
454: int(0)
455: int(512)
456: bool(false)
457: int(0)
458: int(513)
459: bool(false)
460: int(0)
461: int(1024)
462: bool(false)
463: int(0)
464: int(1112)
465: bool(false)
466: int(512)
467: -- File opened in mode x+t --
468: int(0)
469: int(511)
470: bool(false)
471: int(0)
472: int(512)
473: bool(false)
474: int(0)
475: int(513)
476: bool(false)
477: int(0)
478: int(1024)
479: bool(false)
480: int(0)
481: int(1112)
482: bool(false)
483: int(512)
484: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>