//go:build windows

package memorysearch

import (
	"fmt"

	"golang.org/x/sys/windows"
)

func volumeUsage(path string) (free uint64, total uint64, err error) {
	pathPtr, err := windows.UTF16PtrFromString(path)
	if err != nil {
		return 0, 0, fmt.Errorf("memorysearch: encode volume path %s: %w", path, err)
	}
	var totalFree uint64
	if err := windows.GetDiskFreeSpaceEx(pathPtr, &free, &total, &totalFree); err != nil {
		return 0, 0, fmt.Errorf("memorysearch: volume usage %s: %w", path, err)
	}
	return free, total, nil
}
