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