- Fixed type mismatch in disk space calculation (int64 casting) - Created platform-specific disk space implementations: * diskspace_unix.go (Linux, macOS, FreeBSD) * diskspace_windows.go (Windows) * diskspace_bsd.go (OpenBSD) * diskspace_netbsd.go (NetBSD fallback) - All 10 platforms now compile successfully: ✅ Linux (amd64, arm64, armv7) ✅ macOS (Intel, Apple Silicon) ✅ Windows (amd64, arm64) ✅ FreeBSD, OpenBSD, NetBSD
39 lines
751 B
Go
39 lines
751 B
Go
// +build windows
|
|
|
|
package restore
|
|
|
|
import (
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
var (
|
|
kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
|
getDiskFreeSpace = kernel32.NewProc("GetDiskFreeSpaceExW")
|
|
)
|
|
|
|
// getDiskSpace returns available disk space in bytes (Windows)
|
|
func getDiskSpace(path string) (int64, error) {
|
|
var freeBytesAvailable int64
|
|
var totalBytes int64
|
|
var totalFreeBytes int64
|
|
|
|
pathPtr, err := syscall.UTF16PtrFromString(path)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
ret, _, err := getDiskFreeSpace.Call(
|
|
uintptr(unsafe.Pointer(pathPtr)),
|
|
uintptr(unsafe.Pointer(&freeBytesAvailable)),
|
|
uintptr(unsafe.Pointer(&totalBytes)),
|
|
uintptr(unsafe.Pointer(&totalFreeBytes)),
|
|
)
|
|
|
|
if ret == 0 {
|
|
return 0, err
|
|
}
|
|
|
|
return freeBytesAvailable, nil
|
|
}
|