Annotation of embedaddon/php/ext/standard/tests/file/filesize_variation3-win32.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test filesize() function: usage variations - file size after truncate
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: /*
11: Prototype : int filesize ( string $filename );
12: Description : Returns the size of the file in bytes, or FALSE
13: (and generates an error of level E_WARNING) in case of an error.
14: */
15:
16: $file_path = dirname(__FILE__);
17:
18: echo "*** Testing filesize(): usage variations ***\n";
19: $filename = $file_path."/filesize_variation3.tmp";
20: $file_handle = fopen($filename, "w");
21: fwrite($file_handle, (binary)str_repeat("Hello,World ", 1000) ); // create file of size 12000 bytes
22: fclose($file_handle);
23:
24: echo "-- Testing filesize() after truncating the file to a new length --\n";
25: // truncate the file created earlier in subdir, the size of the file is 12000bytes
26: // truncate the same file, in the loop , each time with the decrement in size by 1200 bytes,
27: // until -1200bytes size
28: for($size = filesize($filename); $size>=-1200; $size-=1200) {
29: $file_handle = fopen($filename, "r+");
30: var_dump( ftruncate($file_handle, $size) );
31: fclose($file_handle);
32: var_dump( filesize($filename) );
33: clearstatcache();
34: }
35:
36: echo "*** Done ***\n";
37: ?>
38: --CLEAN--
39: <?php
40: $file_path = dirname(__FILE__);
41: unlink($file_path."/filesize_variation3.tmp");
42: ?>
43: --EXPECTF--
44: *** Testing filesize(): usage variations ***
45: -- Testing filesize() after truncating the file to a new length --
46: bool(true)
47: int(12000)
48: bool(true)
49: int(10800)
50: bool(true)
51: int(9600)
52: bool(true)
53: int(8400)
54: bool(true)
55: int(7200)
56: bool(true)
57: int(6000)
58: bool(true)
59: int(4800)
60: bool(true)
61: int(3600)
62: bool(true)
63: int(2400)
64: bool(true)
65: int(1200)
66: bool(true)
67: int(0)
68: bool(false)
69: int(0)
70: *** Done ***
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>