src/Controller/DevController.php
public function calcDiskSize($path, $bytes = 0)
    {
        if ($this->plugin['files']->exists($path)) {
            if ($this->plugin['files']->isDirectory($path)) {
                foreach ($this->plugin['files']->glob($path) as $file) {
                    $bytes += $this->plugin['files']->size($file);
                }
            } else {
                $bytes += $this->plugin['files']->size($path);
            }
        }
        $units = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
        for ($i = 0; $bytes > 1024; $i++) {
            $bytes /= 1024;
        }
        $size = round($bytes, 2);
        return ($size == 0 ? '-' : $size . ' ' . $units[$i]);
    }
public function calcDiskSize($path, $bytes = 0)
    {
        if ($this->plugin['files']->exists($path)) {
            if ($this->plugin['files']->isDirectory($path)) {
                foreach ($this->plugin['files']->glob($path) as $file) {
                    $bytes += $this->plugin['files']->size($file);
                }
            } else {
                $bytes += $this->plugin['files']->size($path);
            }
        }
        $units = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
        for ($i = 0; $bytes > 1024; $i++) {
            $bytes /= 1024;
        }
        $size = round($bytes, 2);
        return ($size == 0 ? '-' : $size . ' ' . $units[$i]);
    }
public function calcDiskSize ( $ path , $ bytes = 0 ) { if ( $ this -> plugin [ 'files' ] -> exists ( $ path ) ) { if ( $ this -> plugin [ 'files' ] -> isDirectory ( $ path ) ) { foreach ( $ this -> plugin [ 'files' ] -> glob ( $ path ) as $ file ) { $ bytes += $ this -> plugin [ 'files' ] -> size ( $ file ) ; } } else { $ bytes += $ this -> plugin [ 'files' ] -> size ( $ path ) ; } } $ units = [ 'Bytes' , 'KB' , 'MB' , 'GB' , 'TB' , 'PB' ] ; for ( $ i = 0 ; $ bytes > 1024 ; $ i ++ ) { $ bytes /= 1024 ; } $ size = round ( $ bytes , 2 ) ; return ( $ size == 0 ? '-' : $ size . ' ' . $ units [ $ i ] ) ; }
Format File Sizes
@return string
Format File Sizes