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/* 13 * Prototype: array stat ( string $filename ); 14 * Description: Gives information about a file 15 */ 16 17/* test the effects of truncate() on stats of file */ 18 19 20$file_path = dirname(__FILE__); 21require "$file_path/file.inc"; 22 23 24/* create temp file and directory */ 25 26$filename = "$file_path/stat_variation8.tmp"; 27$file_handle = fopen($filename, "w"); // temp file 28fclose($file_handle); 29 30 31echo "\n*** Testing stat(): on file by truncating it to given size ***\n"; 32 33// create temp file 34$file_handle = fopen($filename, "w"); 35fclose($file_handle); 36 37clearstatcache(true, $filename); 38$old_stat = stat($filename); 39// clear the cache 40sleep(2); 41 42// opening file in r/w mode 43$file_handle = fopen($filename, "r+"); 44var_dump( ftruncate($file_handle, 512) ); // truncate it 45fclose($file_handle); 46 47clearstatcache(true, $filename); 48$new_stat = stat($filename); 49 50// compare self stats 51var_dump( compare_self_stat($old_stat) ); 52var_dump( compare_self_stat($new_stat) ); 53 54// compare the stat 55$affected_members = array(7, 9, 'size', 'mtime'); 56var_dump( compare_stats($old_stat, $new_stat, $affected_members, '!=') ); 57 58// clear the stat 59clearstatcache(true, $filename); // clear previous size value in cache 60 61echo "\n*** Done ***"; 62?> 63--CLEAN-- 64<?php 65$file_path = dirname(__FILE__); 66unlink("$file_path/stat_variation8.tmp"); 67?> 68--EXPECT-- 69*** Testing stat(): on file by truncating it to given size *** 70bool(true) 71bool(true) 72bool(true) 73bool(true) 74 75*** Done *** 76