equal
deleted
inserted
replaced
445 } |
445 } |
446 } |
446 } |
447 return |
447 return |
448 } |
448 } |
449 |
449 |
450 // formatSize returns the size in a string with a human-readable format. |
|
451 func formatSize(sizeBytes uint64, short bool) string { |
|
452 var units = map[int]string{ |
|
453 0: "B", |
|
454 1: "KiB", |
|
455 2: "MiB", |
|
456 3: "GiB", |
|
457 4: "TiB", |
|
458 5: "PiB", |
|
459 } |
|
460 humanSize := sizeBytes |
|
461 var n int |
|
462 for n < len(units)-1 { |
|
463 if humanSize < 10000 { |
|
464 break |
|
465 } |
|
466 humanSize /= 1024 |
|
467 n++ |
|
468 } |
|
469 if n < 1 { |
|
470 return fmt.Sprintf("%d bytes", sizeBytes) |
|
471 } |
|
472 if short { |
|
473 return fmt.Sprintf("%d %s", humanSize, units[n]) |
|
474 } |
|
475 return fmt.Sprintf("%d bytes (%d %s)", sizeBytes, humanSize, units[n]) |
|
476 } |
|
477 |
|
478 func duf(dirs []string, options Options) (Results, error) { |
450 func duf(dirs []string, options Options) (Results, error) { |
479 var verbose bool |
451 var verbose bool |
480 if myLog.verbosity > 0 { |
452 if myLog.verbosity > 0 { |
481 verbose = true |
453 verbose = true |
482 } |
454 } |