Started implementation on the new bpm file structure

This commit is contained in:
2024-10-10 12:36:29 +03:00
parent c8939614b1
commit 76efa42bcf
4 changed files with 312 additions and 194 deletions
+13
View File
@@ -1,7 +1,9 @@
package utils
import (
"fmt"
"io"
"math"
"os"
"os/exec"
"strings"
@@ -56,3 +58,14 @@ func stringSliceRemoveEmpty(s []string) []string {
}
return r
}
func BytesToHumanReadable(b uint64) string {
bf := float64(b)
for _, unit := range []string{"", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi"} {
if math.Abs(bf) < 1024.0 {
return fmt.Sprintf("%3.1f%sB", bf, unit)
}
bf /= 1024.0
}
return fmt.Sprintf("%.1fYiB", bf)
}