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