feat: initial commit — unarr CLI
Search, inspect, stream, and download torrents from the terminal. Replaces the entire *arr stack with a single binary.
This commit is contained in:
commit
29cf0a0126
85 changed files with 10178 additions and 0 deletions
31
internal/agent/disk_windows.go
Normal file
31
internal/agent/disk_windows.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//go:build windows
|
||||
|
||||
package agent
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// DiskInfo returns free and total bytes for the filesystem containing path.
|
||||
func DiskInfo(path string) (freeBytes, totalBytes int64, err error) {
|
||||
kernel32 := syscall.NewLazyDLL("kernel32.dll")
|
||||
getDiskFreeSpaceEx := kernel32.NewProc("GetDiskFreeSpaceExW")
|
||||
|
||||
pathPtr, err := syscall.UTF16PtrFromString(path)
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
var freeBytesAvailable, totalNumberOfBytes uint64
|
||||
r1, _, e1 := getDiskFreeSpaceEx.Call(
|
||||
uintptr(unsafe.Pointer(pathPtr)),
|
||||
uintptr(unsafe.Pointer(&freeBytesAvailable)),
|
||||
uintptr(unsafe.Pointer(&totalNumberOfBytes)),
|
||||
0,
|
||||
)
|
||||
if r1 == 0 {
|
||||
return 0, 0, e1
|
||||
}
|
||||
return int64(freeBytesAvailable), int64(totalNumberOfBytes), nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue