* Change file size units from SI to IEC 80000-13:2025 Increase left-padded (%S) file size string length to 5 characters Co-authored-by: Joe Lim <50560759+joelim-work@users.noreply.github.com> * Add note about used IEC units for file size in docs --------- Co-authored-by: Joe Lim <50560759+joelim-work@users.noreply.github.com>
24 lines
419 B
Go
24 lines
419 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
func diskFree(wd string) string {
|
|
var free uint64
|
|
|
|
pathPtr, err := windows.UTF16PtrFromString(wd)
|
|
if err != nil {
|
|
log.Printf("diskfree: %s", err)
|
|
return ""
|
|
}
|
|
err = windows.GetDiskFreeSpaceEx(pathPtr, &free, nil, nil) // cwd, free, total, available
|
|
if err != nil {
|
|
log.Printf("diskfree: %s", err)
|
|
return ""
|
|
}
|
|
return "df: " + humanize(free)
|
|
}
|