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