root

Changeset 631

Show
Ignore:
Timestamp:
07/08/09 03:28:23 (1 year ago)
Author:
wbond
Message:

Fixed fFilesystem::formatFilesize() to work when $bytes equals zero

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fFilesystem.php

    r600 r631 Hide Line Numbers
    1010 * @link       http://flourishlib.com/fFilesystem 
    1111 *  
    12  * @version    1.0.0b6 
     12 * @version    1.0.0b7 
     13 * @changes    1.0.0b7  Fixed ::formatFilesize() to work when `$bytes` equals zero [wb, 2009-07-08] 
    1314 * @changes    1.0.0b6  Changed replacement values in preg_replace() calls to be properly escaped [wb, 2009-06-11] 
    1415 * @changes    1.0.0b5  Changed ::formatFilesize() to use proper uppercase letters instead of lowercase [wb, 2009-06-02] 
     
    236237        $suffixes  = array('B', 'KB', 'MB', 'GB', 'TB'); 
    237238        $sizes     = array(1, 1024, 1048576, 1073741824, 1099511627776); 
    238         $suffix    = floor(log($bytes)/6.9314718); 
     239        $suffix    = (!$bytes) ? 0 : floor(log($bytes)/6.9314718); 
    239240        return number_format($bytes/$sizes[$suffix], $decimal_places) . $suffixes[$suffix]; 
    240241    }