- Add platform-specific implementations for Windows, BSD systems - Create platform-specific disk space checking with proper syscalls - Add Windows process cleanup using tasklist/taskkill - Add BSD-specific Statfs_t field handling (F_blocks, F_bavail, F_bsize) - Support 9/10 target platforms (Linux, Windows, macOS, FreeBSD, OpenBSD) - Process cleanup now works on all Unix-like systems and Windows - Phase 2 TUI improvements compatible across platforms
29 lines
643 B
Go
29 lines
643 B
Go
package checks
|
|
|
|
import "fmt"
|
|
|
|
// DiskSpaceCheck represents disk space information
|
|
type DiskSpaceCheck struct {
|
|
Path string
|
|
TotalBytes uint64
|
|
AvailableBytes uint64
|
|
UsedBytes uint64
|
|
UsedPercent float64
|
|
Sufficient bool
|
|
Warning bool
|
|
Critical bool
|
|
}
|
|
|
|
// formatBytes formats bytes to human-readable format
|
|
func formatBytes(bytes uint64) string {
|
|
const unit = 1024
|
|
if bytes < unit {
|
|
return fmt.Sprintf("%d B", bytes)
|
|
}
|
|
div, exp := uint64(unit), 0
|
|
for n := bytes / unit; n >= unit; n /= unit {
|
|
div *= unit
|
|
exp++
|
|
}
|
|
return fmt.Sprintf("%.1f %ciB", float64(bytes)/float64(div), "KMGTPE"[exp])
|
|
} |