mirror of
https://github.com/TheWhiteDog9487/lag2cn.git
synced 2026-08-11 23:01:29 +08:00
对部分TryParse无法直接完成映射的系统进行特判
虽然现在只要ArchLinux一个,但之后应该会变成部分
This commit is contained in:
+8
-5
@@ -67,21 +67,24 @@ bool ExecuteCommand(string Command,
|
||||
异常信息: {ExceptionMessage}"); };
|
||||
WhenErrorThrown(ExitCode, string.Join("\n", StandardError), ExceptionInstance.Message);
|
||||
return false; } }
|
||||
|
||||
if (Enum.TryParse<SupportedLinuxDistributions>(RuntimeInformation.OSDescription, out var CurrentSystem) == false){
|
||||
string OsDescription = RuntimeInformation.OSDescription;
|
||||
if (Enum.TryParse<SupportedLinuxDistributions>(OsDescription.Split(' ')[0], out var CurrentSystem) == false){
|
||||
if (OsDescription.Contains("Arch Linux")){
|
||||
CurrentSystem = SupportedLinuxDistributions.ArchLinux; }
|
||||
else{
|
||||
string CurrentSuppoetedLinuxDistributions = string.Join(", ", Enum.GetNames<SupportedLinuxDistributions>());
|
||||
string Message = @$"
|
||||
当前系统为 {RuntimeInformation.OSDescription}
|
||||
当前系统为 {OsDescription}
|
||||
当前仅支持 {CurrentSuppoetedLinuxDistributions}
|
||||
强行使用可能会造成不可预知的问题
|
||||
为避免出现故障,程序会强制退出
|
||||
如果是误报,请在GitHub仓库打开一个新的issue。
|
||||
".Trim();
|
||||
throw new NotSupportedException(Message); }
|
||||
throw new NotSupportedException(Message); } }
|
||||
if (GetEffectiveUserId() != 0){
|
||||
throw new UnauthorizedAccessException("更改语言文件需要root权限,请使用sudo重新运行本程序"); }
|
||||
|
||||
Console.WriteLine($"探测到当前系统为 {RuntimeInformation.OSDescription}");
|
||||
Console.WriteLine($"探测到当前系统为 {OsDescription}");
|
||||
switch (CurrentSystem){
|
||||
case SupportedLinuxDistributions.Debian or SupportedLinuxDistributions.Armbian: {
|
||||
CheckUser();
|
||||
|
||||
Reference in New Issue
Block a user