Edit report at http://pear.php.net/bugs/bug.php?id=2798&edit=1
ID: 2798
Updated by: [email protected]
Reported By: cweiske at php dot net
Summary: function for human readable filesize conversion
Status: Open
Type: Feature/Change Request
-Package: File
+Package: File_Util
Operating System: -
PHP Version: -
-Assigned To:
+Assigned To: cweiske
Roadmap Versions:
New Comment:
-Package: File
+Package: File_Util
-Assigned To:
+Assigned To: cweiske
Previous Comments:
------------------------------------------------------------------------
[2010-04-09 12:14:40] cweiske
please add the patch.
------------------------------------------------------------------------
[2010-04-08 03:01:17] samwilson
I am using a variation of Christian's function, with the following
header and signature:
/**
* Returns a file's size with a human-readable suffix such as
"kilobytes", "MB",
* "mebibytes", "TB", etc.
*
* @param string|integer|array $file The name of the file, or a file
size in
* bytes (or an array of these).
* @param integer $decimals The precision or number of
digits after the
* decimal point.
* @param boolean $long Use long names (kilobyte) and a
space
* instead of short ones (kB) and
no space.
* @param boolean $useSI Whether units should be
multiples of
* 1000 (true) or 1024 (false).
* @param boolean $useBiBytes If the "BiBytes" names should
be used
* (applies only when $useSI =
true).
*
* @return string|array The filesize in human readable format (or
array of same).
* @access public
* @static
*/
function filesize($file, $decimals = 2, $long = false, $useSI =
true, $useBiBytes = true)
{
/* ... */
}
I will submit a patch if there is agreement about these changes (i.e.
different parameters and defaults; the function still does the same
thing).
------------------------------------------------------------------------
[2009-08-06 08:57:03] cweiske
The following patch has been added/updated:
Patch Name: human-readabe.phpt
Revision: 1249545423
URL:
http://pear.php.net/bugs/patch-display.php?bug=2798&patch=human-readabe.phpt&revision=1249545423&display=1
------------------------------------------------------------------------
[2009-08-06 08:56:42] cweiske
The following patch has been added/updated:
Patch Name: readable.diff
Revision: 1249545402
URL:
http://pear.php.net/bugs/patch-display.php?bug=2798&patch=readable.diff&revision=1249545402&display=1
------------------------------------------------------------------------
[2006-06-03 06:27:56] aidan
Found this bug accidently on googly, if you still want to include a
function like this in the File class:
http://aidanlister.com/repos/v/function.size_readable.php
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://pear.php.net/bugs/bug.php?id=2798