1--TEST--
2Test filesize() function: usage variations - size of dir/subdir
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die('skip only valid for Linux');
7}
8?>
9--FILE--
10<?php
11$file_path = __DIR__;
12require($file_path."/file.inc");
13
14echo "*** Testing filesize(): usage variations ***\n";
15
16echo "\n*** Testing size of a dir, sub-dir and file with filesize() ***\n";
17echo "-- Creating a base dir, and checking its size --\n";
18mkdir( $file_path."/filesize_variation2");
19var_dump( filesize( $file_path."/filesize_variation2"));
20clearstatcache();
21
22echo "-- Creating a file inside base dir, and checking dir & file size --\n";
23create_files($file_path."/filesize_variation2", 1, "numeric", 0755, 1, "w", "filesize_variation");
24var_dump( filesize( $file_path."/filesize_variation2"));
25clearstatcache();
26var_dump( filesize( $file_path."/filesize_variation2/filesize_variation1.tmp"));
27clearstatcache();
28delete_files($file_path."/filesize_variation2", 1, "filesize_variation");
29
30echo "-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir --\n";
31mkdir( $file_path."/filesize_variation2/filesize_variation2_sub");
32var_dump( filesize( $file_path."/filesize_variation2")); // size of base dir
33clearstatcache();
34var_dump( filesize( $file_path."/filesize_variation2/filesize_variation2_sub")); // size of subdir
35clearstatcache();
36
37echo "-- Creating a file inside sub-dir, and checking size of base, subdir and file created --\n";
38// create only the file, as base and subdir is already created
39$filename =  $file_path."/filesize_variation2/filesize_variation2_sub/filesize_variation2.tmp";
40$file_handle = fopen($filename, "w");
41fwrite($file_handle, str_repeat("Hello,World ", 1000) ); // create file of size 12000 bytes
42fclose($file_handle);
43// size of base dir
44var_dump( filesize( $file_path."/filesize_variation2"));
45clearstatcache();
46// size of subdir
47var_dump( filesize( $file_path."/filesize_variation2/filesize_variation2_sub"));
48clearstatcache();
49// size of file inside subdir
50var_dump( filesize( $file_path."/filesize_variation2/filesize_variation2_sub/filesize_variation2.tmp"));
51clearstatcache();
52
53echo "*** Done ***\n";
54?>
55--CLEAN--
56<?php
57$file_path = __DIR__;
58unlink($file_path."/filesize_variation2/filesize_variation2_sub/filesize_variation2.tmp");
59rmdir($file_path."/filesize_variation2/filesize_variation2_sub");
60rmdir($file_path."/filesize_variation2");
61?>
62--EXPECTF--
63*** Testing filesize(): usage variations ***
64
65*** Testing size of a dir, sub-dir and file with filesize() ***
66-- Creating a base dir, and checking its size --
67int(%d)
68-- Creating a file inside base dir, and checking dir & file size --
69int(%d)
70int(1024)
71-- Creating an empty sub-dir in base-dir, and checking size of base and sub dir --
72int(%d)
73int(%d)
74-- Creating a file inside sub-dir, and checking size of base, subdir and file created --
75int(%d)
76int(%d)
77int(12000)
78*** Done ***
79