note 22237 added to function.filesize
| From: | andudi at gmx dot ch | Date: | Tue, 11 Jun 2002 20:45:12 +0000 |
| Subject: | note 22237 added to function.filesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-31712@lists.php.net to get a copy of this message | ||
To find the total size of a file/directory you have to differ two
situations:
(on Linux/Unix based systems only!?)
you are interested:
1) in the total size of the files in the dir/subdirs
2) what place on the disk your dir/subdirs/files uses
- 1) and 2) normaly differs, depending on the size of the inodes
- mostly 2) is greater than 1) (in the order of any kB)
- filesize($file) gives 1)
- "du -ab $file" gives 2)
so you have to choose your situation!
on my server I have no rights to use "exec du" in the case of
2), so I use:
$s = stat($file);
$size = $s[11]*$s[12]/8);
whitch is counting the inodes [12] times the size of them in Bits [11]
hopes this helps to count the used disk place in a right way... :-)
Andreas Dick
--
http://www.php.net/manual/en/function.filesize.php
http://master.php.net/manage/user-notes.php?action=edit+22237
http://master.php.net/manage/user-notes.php?action=delete+22237
http://master.php.net/manage/user-notes.php?action=reject+22237