I have modify my folder.php in sapphire/filesystem/Folder
to be able to get the size of a folder directly with a folder object, I have ovverrides the function getAbsoluteSize of file
this is called reccursivily ion case of folder inside the folder..
//return the size in octet
public function getAbsoluteSize($path='')
{
if(empty($path))
{
$path = Director::baseFolder() . '/' . $this->getRelativePath();
}
$h = @opendir($path);
if($h==0)return 0;
$sf = 0;
while ($f = readdir($h))
{
if ( $f!= "..")
{
$nd = $path ."/". $f ;
if( $f!=".")
$sf += filesize( $nd );
if( $f!="." && is_dir($nd))
{
$nd = $path . $f ;
$sf+= $this->getAbsoluteSize( $nd );
}
}
}
closedir($h);
return $sf ;
}
For information, you can do it also with a shell but this requires 751 CHmod on the folder (more access..less security)
$folder = "home/tea/mail/";
if($pass === "eggnut") {
$job = shell_exec("du -s -k $folder"); //summary
echo "<b>SIZE in KB:</b> $job";
I do not like to change my core, for the further versionning.
But I do not need another class folder, and actually $Myfolder->getAbsoluteSize() exist and does not give the good result.
If a guy of the core dev read this post do you think,; it culd be a good think to integreta this to the further versions.
Thanks.
Your framework is awesome guys !
10 of people , developers & others
Mike