function drush_format_size
8.0.x drush.inc | drush_format_size($size) |
6.x drush.inc | drush_format_size($size, $langcode = NULL) |
7.x drush.inc | drush_format_size($size, $langcode = NULL) |
3.x drush.inc | drush_format_size($size, $langcode = NULL) |
4.x drush.inc | drush_format_size($size, $langcode = NULL) |
5.x drush.inc | drush_format_size($size, |
master drush.inc | drush_format_size($size) |
Related topics
1 call to drush_format_size()
- Logger::log in lib/
Drush/ Log/ Logger.php
File
- includes/
drush.inc, line 1466 - The drush API implementation and helpers.
Code
function drush_format_size($size) {
if ($size < DRUSH_KILOBYTE) {
// format_plural() not always available.
return dt('@count bytes', array('@count' => $size));
}
else {
$size = $size / DRUSH_KILOBYTE; // Convert bytes to kilobytes.
$units = array(
dt('@size KB', array()),
dt('@size MB', array()),
dt('@size GB', array()),
dt('@size TB', array()),
dt('@size PB', array()),
dt('@size EB', array()),
dt('@size ZB', array()),
dt('@size YB', array()),
);
foreach ($units as $unit) {
if (round($size, 2) >= DRUSH_KILOBYTE) {
$size = $size / DRUSH_KILOBYTE;
}
else {
break;
}
}
return str_replace('@size', round($size, 2), $unit);
}
}