FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=2798&edit=1

ID: 2798
Updated by: helgith@gmail.com
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

Search Discussions

  • Helgith at Mar 11, 2011 at 11:10 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=2798&edit=1

    ID: 2798
    Updated by: helgith@gmail.com
    Reported By: cweiske at php dot net
    Summary: function for human readable filesize conversion
    -Status: Assigned
    +Status: Closed
    Type: Feature/Change Request
    Package: File_Util
    Operating System: -
    PHP Version: -
    Assigned To: cweiske
    Roadmap Versions:
    New Comment:

    -Status: Assigned
    +Status: Closed
    This bug has been fixed in SVN.

    If this was a documentation problem, the fix will appear on pear.php.net
    by the end of next Sunday (CET).

    If this was a problem with the pear.php.net website, the change should
    be live shortly.

    Otherwise, the fix will appear in the package's next release.

    Thank you for the report and for helping us make PEAR better.




    Previous Comments:
    ------------------------------------------------------------------------

    [2011-03-12 00:09:46] dufuz

    -Package: File
    +Package: File_Util
    -Assigned To:
    +Assigned To: cweiske


    ------------------------------------------------------------------------

    [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

    ------------------------------------------------------------------------

    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedMar 11, '11 at 11:06p
activeMar 11, '11 at 11:10p
posts2
users1
websitepear.php.net

1 user in discussion

Helgith: 2 posts

People

Translate

site design / logo © 2022 Grokbase