2
Test stat() functions: usage variations - effects of rename()
5
if (substr(PHP_OS, 0, 3) != 'WIN') {
6
die('skip.. only for Windows');
13
* Prototype: array stat ( string $filename );
14
* Description: Gives information about a file
17
/* test the effects of rename() on stats of dir/file */
19
$file_path = dirname(__FILE__);
20
require "$file_path/file.inc";
23
/* create temp file and directory */
24
mkdir("$file_path/stat_variation1/"); // temp dir
26
$file_handle = fopen("$file_path/stat_variation1.tmp", "w"); // temp file
30
echo "*** Testing stat(): on file and directory ater renaming them ***\n";
33
echo "-- Testing stat() for files after being renamed --\n";
34
$old_filename = "$file_path/stat_variation1.tmp";
35
$new_filename = "$file_path/stat_variation1a.tmp";
36
$old_stat = stat($old_filename);
39
var_dump( rename($old_filename, $new_filename) );
40
$new_stat = stat($new_filename);
42
// compare the self stat
43
var_dump( compare_self_stat($old_stat) );
44
var_dump( compare_self_stat($new_stat) );
46
// compare the two stats
47
var_dump( compare_stats($old_stat, $old_stat, $all_stat_keys) );
51
// renaming a directory
52
echo "-- Testing stat() for directory after being renamed --\n";
53
$old_dirname = "$file_path/stat_variation1";
54
$new_dirname = "$file_path/stat_variation1a";
55
$old_stat = stat($old_dirname);
58
var_dump( rename($old_dirname, $new_dirname) );
59
$new_stat = stat($new_dirname);
62
var_dump( compare_self_stat($old_stat) );
63
var_dump( compare_self_stat($new_stat) );
65
// compare the two stats
66
var_dump( compare_stats($old_stat, $new_stat, $all_stat_keys) );
71
echo "\n*** Done ***";
76
$file_path = dirname(__FILE__);
77
unlink("$file_path/stat_variation1a.tmp");
78
rmdir("$file_path/stat_variation1a");
81
*** Testing stat(): on file and directory ater renaming them ***
82
-- Testing stat() for files after being renamed --
87
-- Testing stat() for directory after being renamed --