Accept hosts.ics as a host file on windows.

Signed-off-by: 秋雨落 <i@rain.cx>
This commit is contained in:
秋雨落 2026-01-28 18:24:48 +08:00
parent 9ea80671d3
commit 2d643003e5
No known key found for this signature in database
GPG key ID: 91161F0ED680D737

View file

@ -719,10 +719,9 @@ public class Utils
return Guid.TryParse(strSrc, out _);
}
public static Dictionary<string, string> GetSystemHosts()
private static Dictionary<string, string> GetSystemHosts(string hostFile)
{
var systemHosts = new Dictionary<string, string>();
var hostFile = @"C:\Windows\System32\drivers\etc\hosts";
try
{
if (File.Exists(hostFile))
@ -755,6 +754,19 @@ public class Utils
return systemHosts;
}
public static Dictionary<string, string> GetSystemHosts()
{
var hosts = GetSystemHosts(@"C:\Windows\System32\drivers\etc\hosts");
var hostsIcs = GetSystemHosts(@"C:\Windows\System32\drivers\etc\hosts.ics");
foreach (var (key, value) in hostsIcs)
{
hosts[key] = value;
}
return hosts;
}
public static async Task<string?> GetCliWrapOutput(string filePath, string? arg)
{
return await GetCliWrapOutput(filePath, arg != null ? new List<string>() { arg } : null);