//go:build !windows

package agent

import (
	"os"
	"syscall"
)

func chmodPiPath(path string, mode os.FileMode, directory bool) error {
	flags := os.O_WRONLY | syscall.O_NOFOLLOW
	if directory {
		flags = os.O_RDONLY | syscall.O_DIRECTORY | syscall.O_NOFOLLOW
	}
	file, err := os.OpenFile(path, flags, 0)
	if err != nil {
		return err
	}
	defer file.Close()
	return file.Chmod(mode)
}
