MCPcopy Create free account
hub / github.com/MertJSX/folderhost / ConvertBytesToString

Function ConvertBytesToString

utils/convert_bytes_to_string.go:8–23  ·  view source on GitHub ↗
(bytes int64)

Source from the content-addressed store, hash-verified

6)
7
8func ConvertBytesToString(bytes int64) string {
9 sizes := []string{"Bytes", "KB", "MB", "GB", "TB"}
10 var bytesFloat float64 = float64(bytes)
11
12 if bytes == 0 {
13 return "0 Bytes"
14 }
15
16 var i int = int(math.Floor(math.Log(bytesFloat) / math.Log(1024)))
17
18 if i == 0 {
19 return fmt.Sprintf("%d %s", bytes, sizes[i])
20 }
21
22 return fmt.Sprintf("%.1f %s", (bytesFloat / math.Pow(1024, float64(i))), sizes[i])
23}

Callers 10

ListServicesMethod · 0.92
ListAllowedServicesMethod · 0.92
GetServiceStatusMethod · 0.92
StartMonitoringMethod · 0.92
HandleUnzipFunction · 0.92
HandleZipFunction · 0.92
DeleteFunction · 0.92
ReadDirectoryFunction · 0.92
GetDirectoryItemsFunction · 0.85
GetDirectorySizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected