1--TEST-- 2Test stat() functions: usage variations - effects of truncate() 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) != 'WIN') { 6 die('skip.. only for Windows'); 7} 8?> 9--FILE-- 10<?php 11 12/* test the effects of truncate() on stats of file */ 13 14 15$file_path = __DIR__; 16require "$file_path/file.inc"; 17 18 19/* create temp file and directory */ 20 21$filename = "$file_path/stat_variation8.tmp"; 22$file_handle = fopen($filename, "w"); // temp file 23fclose($file_handle); 24 25 26echo "\n*** Testing stat(): on file by truncating it to given size ***\n"; 27 28// create temp file 29$file_handle = fopen($filename, "w"); 30fclose($file_handle); 31 32clearstatcache(true, $filename); 33$old_stat = stat($filename); 34// clear the cache 35sleep(1); 36 37// opening file in r/w mode 38$file_handle = fopen($filename, "r+"); 39var_dump( ftruncate($file_handle, 512) ); // truncate it 40fclose($file_handle); 41 42clearstatcache(true, $filename); 43$new_stat = stat($filename); 44 45// compare self stats 46var_dump( compare_self_stat($old_stat) ); 47var_dump( compare_self_stat($new_stat) ); 48 49// compare the stat 50$affected_members = array(7, 9, 'size', 'mtime'); 51var_dump( compare_stats($old_stat, $new_stat, $affected_members, '!=') ); 52 53// clear the stat 54clearstatcache(true, $filename); // clear previous size value in cache 55 56echo "\n*** Done ***"; 57?> 58--CLEAN-- 59<?php 60$file_path = __DIR__; 61unlink("$file_path/stat_variation8.tmp"); 62?> 63--EXPECT-- 64*** Testing stat(): on file by truncating it to given size *** 65bool(true) 66bool(true) 67bool(true) 68bool(true) 69 70*** Done *** 71