1--TEST-- 2Test lstat() and stat() functions: usage variations - effects of truncate() 3--SKIPIF-- 4<?php 5if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); 6if (substr(PHP_OS, 0, 3) == 'WIN') { 7 die('skip.. Not valid for Windows'); 8} 9?> 10--FILE-- 11<?php 12/* Prototype: array lstat ( string $filename ); 13 Description: Gives information about a file or symbolic link 14 15 Prototype: array stat ( string $filename ); 16 Description: Gives information about a file 17*/ 18 19/* test the effects of truncate() on stats of a file */ 20 21$file_path = dirname(__FILE__); 22require "$file_path/file.inc"; 23 24 25/* create temp file */ 26$filename = "$file_path/lstat_stat_variation21.tmp"; 27$fp = fopen($filename, "w"); // temp file 28fclose($fp); 29 30/* ftruncate the current file and check stat() on the file */ 31 32echo "*** Testing stat() on file by truncating it to given size ***\n"; 33$old_stat = stat($filename); 34// clear the cache 35clearstatcache(); 36sleep(2); 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 42$new_stat = stat($filename); 43// compare self stats 44var_dump( compare_self_stat($old_stat) ); 45var_dump( compare_self_stat($new_stat) ); 46// compare the stat 47$affected_members = array(7, 9, 10, 'size', 'mtime', 'ctime'); 48var_dump( compare_stats($old_stat, $new_stat, $affected_members, '!=') ); 49 50echo "\n--- Done ---"; 51?> 52--CLEAN-- 53<?php 54$file_path = dirname(__FILE__); 55unlink("$file_path/lstat_stat_variation21.tmp"); 56?> 57--EXPECT-- 58*** Testing stat() on file by truncating it to given size *** 59bool(true) 60bool(true) 61bool(true) 62bool(true) 63 64--- Done --- 65