CI_Profiler::get_file_size PHP Method

get_file_size() public static method

--------------------------------------------------------------------
public static get_file_size ( $size, $retstring = null )
    public static function get_file_size($size, $retstring = null)
    {
        // adapted from code at http://aidanlister.com/repos/v/function.size_readable.php
        $sizes = array('bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
        if ($retstring === null) {
            $retstring = '%01.2f %s';
        }
        $lastsizestring = end($sizes);
        foreach ($sizes as $sizestring) {
            if ($size < 1024) {
                break;
            }
            if ($sizestring != $lastsizestring) {
                $size /= 1024;
            }
        }
        if ($sizestring == $sizes[0]) {
            $retstring = '%01d %s';
        }
        // Bytes aren't normally fractional
        return sprintf($retstring, $size, $sizestring);
    }