//go:build !windows

package memorysearch

import (
	"fmt"

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

func volumeUsage(path string) (free uint64, total uint64, err error) {
	var stat unix.Statfs_t
	if err := unix.Statfs(path, &stat); err != nil {
		return 0, 0, fmt.Errorf("memorysearch: statfs %s: %w", path, err)
	}
	blockSize := uint64(stat.Bsize)
	return stat.Bavail * blockSize, stat.Blocks * blockSize, nil
}
