summaryrefslogtreecommitdiffstats
path: root/etc/inc/util.inc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2008-08-23 19:11:59 +0000
committerScott Ullrich <sullrich@pfsense.org>2008-08-23 19:11:59 +0000
commit44bfd1fabdf1c08993ed154a756d114399f54e0a (patch)
tree98788c6e3134ea6921c8b4b6f3646d4c1a1abd03 /etc/inc/util.inc
parentacdbfa048920303e385f3fb8c14e71c3ef19d22e (diff)
downloadpfsense-44bfd1fabdf1c08993ed154a756d114399f54e0a.zip
pfsense-44bfd1fabdf1c08993ed154a756d114399f54e0a.tar.gz
Import format_bytes() from m0n0wall
Diffstat (limited to 'etc/inc/util.inc')
-rw-r--r--etc/inc/util.inc14
1 files changed, 13 insertions, 1 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index f6063ea..9810ede 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -662,4 +662,16 @@ function resolve_retry($hostname, $retries = 5) {
return false;
}
-?>
+function format_bytes($bytes) {
+ if ($bytes >= 1073741824) {
+ return sprintf("%.2f GB", $bytes/1073741824);
+ } else if ($bytes >= 1048576) {
+ return sprintf("%.2f MB", $bytes/1048576);
+ } else if ($bytes >= 1024) {
+ return sprintf("%.0f KB", $bytes/1024);
+ } else {
+ return sprintf("%d bytes", $bytes);
+ }
+}
+
+?> \ No newline at end of file
OpenPOWER on IntegriCloud