Files
dnshelper/fileoperations_windows.go
T
2026-03-03 13:58:06 -05:00

28 lines
579 B
Go

//go:build windows
package main
import (
"errors"
"os"
)
func getHostsFileLocation() (string, error) {
//return "hosts", nil
var hostsFileLocation string
value, envExists := os.LookupEnv("SystemRoot")
if envExists {
hostsFileLocation = value + "\\System32\\drivers\\etc\\hosts"
} else {
hostsFileLocation = "C:\\Windows\\System32\\drivers\\etc\\hosts"
}
exists, err := fileExists(hostsFileLocation)
if err != nil {
return "", err
}
if exists == false {
return "", errors.New("file does not exist: " + hostsFileLocation)
}
return hostsFileLocation, nil
}