Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




recurse_dirsize [ WordPress Function ]

recurse_dirsize ( $directory )
Parameters:
  • (string) $directory
Returns:
  • (int)
Defined at:



Get the size of a directory recursively.

Used by get_dirsize() to get a directory's size when it contains other directories.

Source


<?php
function recurse_dirsize$directory ) {
    
$size 0;

    
$directory untrailingslashit$directory );

    if ( !
file_exists($directory) || !is_dir$directory ) || !is_readable$directory ) )
        return 
false;

    if (
$handle opendir($directory)) {
        while((
$file readdir($handle)) !== false) {
            
$path $directory.'/'.$file;
            if (
$file != '.' && $file != '..') {
                if (
is_file($path)) {
                    
$size += filesize($path);
                } elseif (
is_dir($path)) {
                    
$handlesize recurse_dirsize($path);
                    if (
$handlesize 0)
                        
$size += $handlesize;
                }
            }
        }
        
closedir($handle);
    }
    return 
$size;
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

Gebruikersdiscussies [ wordpress.org ]

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics