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