Ignore:
Timestamp:
Aug 29, 2008 8:30:19 AM (16 years ago)
Author:
quinn
Message:

Added argument to Utilities's humanFileSize function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Utilities.inc.php

    r336 r338  
    266266    case 'end' :
    267267        return preg_replace(array(sprintf('/^(.{%s}).{4,}$/sU', $part1 + $part2), '/\s*\.{3,}\s*/sU'), array('$1' . $delim, $delim), $str);
    268         break;   
    269     }
    270 }
    271 
    272 /**
    273  * Return a human readable filesize.
    274  *
    275  * @param       int    $size        Size
     268        break;
     269    }
     270}
     271
     272/**
     273 * Return a human readable disk space measurement. Input value measured in bytes.
     274 *
     275 * @param       int    $size        Size in bytes.
    276276 * @param       int    $unit        The maximum unit
    277277 * @param       int    $format      The return string format
     
    279279 * @version     1.1.0
    280280 */
    281 function humanFileSize($size, $format='%01.2f %s', $max_unit=null)
     281function humanFileSize($size, $format='%01.2f %s', $max_unit=null, $multiplier=1024)
    282282{
    283283    // Units
     
    293293    // Loop
    294294    $i = 0;
    295     while ($max_unit != $i && $size >= 1024 && $i < $ii) {
    296         $size /= 1024;
     295    while ($max_unit != $i && $size >= $multiplier && $i < $ii) {
     296        $size /= $multiplier;
    297297        $i++;
    298298    }
Note: See TracChangeset for help on using the changeset viewer.