From a6d77ad008b9c5f8f1fac79b6a0414dedd06c85d Mon Sep 17 00:00:00 2001 From: Shadow Eevee Date: Fri, 3 Apr 2020 16:36:26 -0500 Subject: [PATCH] Countinue cross-platform Exit Code fixes --- Sharpii/Program.cs | 38 +++++++- Sharpii/TPL.cs | 63 +++++++++++-- Sharpii/U8.cs | 63 +++++++++++-- Sharpii/WAD.cs | 225 ++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 346 insertions(+), 43 deletions(-) diff --git a/Sharpii/Program.cs b/Sharpii/Program.cs index 59bfa24..5d30903 100644 --- a/Sharpii/Program.cs +++ b/Sharpii/Program.cs @@ -41,7 +41,15 @@ namespace Sharpii Console.WriteLine("This should not appear on the .Net Core port."); Console.WriteLine("If you see this, report how you got here on https://github.com/TheShadowEevee/Sharpii-NetCore/issues."); Console.WriteLine("Error: SHARPII_NET_CORE_MAIN_MISSING_DLL_LIBWIISHARP_01"); - Environment.Exit(0x00003E8F); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E8F); + } + else + { + Environment.Exit(0x00000011); + } + return; } for (int i = 1; i < args.Length; i++) @@ -159,7 +167,15 @@ namespace Sharpii //If tuser gets here, they entered something wrong Console.WriteLine("ERROR: The argument {0} is invalid", args[0]); Console.WriteLine("Error: SHARPII_NET_CORE_MAIN_INVALID_ARG_01"); - Environment.Exit(0x00003E90); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E90); + } + else + { + Environment.Exit(0x00000012); + } + return; } string temp = Path.GetTempPath() + "Sharpii.tmp"; @@ -204,7 +220,14 @@ namespace Sharpii catch (Exception ex) { Console.WriteLine("An unknown error occured, please try again\n\nERROR DETAILS: {0}", ex.Message); - Environment.Exit(0x00003E82); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E82); + } + else + { + Environment.Exit(0x00000004); + } return; } } @@ -224,7 +247,14 @@ namespace Sharpii catch (Exception ex) { Console.WriteLine("An unknown error occured, please try again\n\nERROR DETAILS: {0}", ex.Message); - Environment.Exit(0x00003E82); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E82); + } + else + { + Environment.Exit(0x00000004); + } return; } } diff --git a/Sharpii/TPL.cs b/Sharpii/TPL.cs index 20e6289..9303f56 100644 --- a/Sharpii/TPL.cs +++ b/Sharpii/TPL.cs @@ -49,7 +49,14 @@ namespace Sharpii //If tuser gets here, they entered something wrong Console.WriteLine("ERROR: The argument {0} is invalid", args[1]); Console.WriteLine("Error: SHARPII_NET_CORE_TPL_INVALID_ARG_01"); - Environment.Exit(0x00003E90); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E90); + } + else + { + Environment.Exit(0x00000012); + } return; } @@ -65,7 +72,14 @@ namespace Sharpii Console.WriteLine("ERROR: Unable to open file: {0}", input); Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it."); Console.WriteLine("Error: SHARPII_NET_CORE_TPL_FILE_ERR_01"); - Environment.Exit(0x00003E81); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E81); + } + else + { + Environment.Exit(0x00000003); + } return; } @@ -99,7 +113,14 @@ namespace Sharpii Console.WriteLine(""); Console.WriteLine("ERROR DETAILS: {0}", ex.Message); Console.WriteLine("Error: SHARPII_NET_CORE_TPL_UNKNOWN_01"); - Environment.Exit(0x00003E82); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E81); + } + else + { + Environment.Exit(0x00000003); + } return; } } @@ -117,7 +138,14 @@ namespace Sharpii Console.WriteLine("ERROR: Unable to open file: {0}", input); Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it."); Console.WriteLine("Error: SHARPII_NET_CORE_TPL_FILE_ERR_01"); - Environment.Exit(0x00003E81); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E81); + } + else + { + Environment.Exit(0x00000003); + } return; } @@ -131,7 +159,14 @@ namespace Sharpii { Console.WriteLine("ERROR: No format set"); Console.WriteLine("Error: SHARPII_NET_CORE_TPL_NO_FORMAT_01"); - Environment.Exit(0x00003E91); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E91); + } + else + { + Environment.Exit(0x00000013); + } return; } tplFormat = args[i + 1]; @@ -141,7 +176,14 @@ namespace Sharpii { Console.WriteLine("ERROR: No format set"); Console.WriteLine("Error: SHARPII_NET_CORE_TPL_NO_FORMAT_01"); - Environment.Exit(0x00003E91); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E91); + } + else + { + Environment.Exit(0x00000013); + } return; } tplFormat = args[i + 1]; @@ -212,7 +254,14 @@ namespace Sharpii Console.WriteLine(""); Console.WriteLine("ERROR DETAILS: {0}", ex.Message); Console.WriteLine("Error: SHARPII_NET_CORE_TPL_UNKNOWN_01"); - Environment.Exit(0x00003E82); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E82); + } + else + { + Environment.Exit(0x00000004); + } return; } } diff --git a/Sharpii/U8.cs b/Sharpii/U8.cs index 9088e5f..808951a 100644 --- a/Sharpii/U8.cs +++ b/Sharpii/U8.cs @@ -49,7 +49,14 @@ namespace Sharpii //If tuser gets here, they entered something wrong Console.WriteLine("ERROR: The argument {0} is invalid", args[1]); Console.WriteLine("Error: SHARPII_NET_CORE_U8_INVALID_ARG_01"); - Environment.Exit(0x00003E90); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E90); + } + else + { + Environment.Exit(0x00000012); + } return; } @@ -72,7 +79,14 @@ namespace Sharpii { Console.WriteLine("ERROR: File {0} is not a U8 archive", input); Console.WriteLine("Error: SHARPII_NET_CORE_U8_NON_U8_01"); - Environment.Exit(0x00003E93); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E93); + } + else + { + Environment.Exit(0x00000015); + } return; } @@ -107,7 +121,14 @@ namespace Sharpii Console.WriteLine(""); Console.WriteLine("ERROR DETAILS: {0}", ex.Message); Console.WriteLine("Error: SHARPII_NET_CORE_U8_UNKNOWN_01"); - Environment.Exit(0x00003E82); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E82); + } + else + { + Environment.Exit(0x00000004); + } return; } } @@ -127,7 +148,14 @@ namespace Sharpii Console.WriteLine("ERROR: Unable to open Folder: {0}", input); Console.WriteLine("Either the folder doesn't exist, or Sharpii doesn't have permission to open it."); Console.WriteLine("Error: SHARPII_NET_CORE_U8_FOLDER_ERR_01"); - Environment.Exit(0x00003E94); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E94); + } + else + { + Environment.Exit(0x00000016); + } return; } @@ -146,7 +174,14 @@ namespace Sharpii { Console.WriteLine("ERROR: No title set"); Console.WriteLine("Error: SHARPII_NET_CORE_U8_NO_TITLE_01"); - Environment.Exit(0x00003E95); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E95); + } + else + { + Environment.Exit(0x00000017); + } return; } imet = args[i + 1]; @@ -158,7 +193,14 @@ namespace Sharpii { Console.WriteLine("ERROR: Cannot use IMET and IMD5 at the same time."); Console.WriteLine("Error: SHARPII_NET_CORE_U8_TWO_HEADERS_01"); - Environment.Exit(0x00003E96); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E96); + } + else + { + Environment.Exit(0x00000018); + } return; } @@ -211,7 +253,14 @@ namespace Sharpii Console.WriteLine(""); Console.WriteLine("ERROR DETAILS: {0}", ex.Message); Console.WriteLine("Error: SHARPII_NET_CORE_U8_UNKNOWN_01"); - Environment.Exit(0x00003E82); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E82); + } + else + { + Environment.Exit(0x00000004); + } return; } } diff --git a/Sharpii/WAD.cs b/Sharpii/WAD.cs index 3d0ff65..9ee837f 100644 --- a/Sharpii/WAD.cs +++ b/Sharpii/WAD.cs @@ -82,7 +82,14 @@ namespace Sharpii //If tuser gets here, they entered something wrong Console.WriteLine("ERROR: The argument {0} is invalid", args[1]); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_INVALID_ARG_01"); - Environment.Exit(0x00003E90); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E90); + } + else + { + Environment.Exit(0x00000012); + } return; } @@ -99,7 +106,14 @@ namespace Sharpii Console.WriteLine("ERROR: Unable to open file: {0}", input); Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it."); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_FILE_ERR_01"); - Environment.Exit(0x00003E81); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E81); + } + else + { + Environment.Exit(0x00000003); + } return; } @@ -112,7 +126,14 @@ namespace Sharpii { Console.WriteLine("ERROR: No output set"); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_NO_OUTPUT_01"); - Environment.Exit(0x00003E8D); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E8D); + } + else + { + Environment.Exit(0x0000000F); + } return; } output = args[i + 1]; @@ -122,7 +143,14 @@ namespace Sharpii { Console.WriteLine("ERROR: No output set"); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_NO_OUTPUT_01"); - Environment.Exit(0x00003E8D); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E8D); + } + else + { + Environment.Exit(0x0000000F); + } return; } output = args[i + 1]; @@ -216,7 +244,14 @@ namespace Sharpii Console.WriteLine(""); Console.WriteLine("ERROR DETAILS: {0}", ex.Message); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_UNKNOWN_01"); - Environment.Exit(0x00003E82); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E82); + } + else + { + Environment.Exit(0x00000004); + } return; } } @@ -243,7 +278,14 @@ namespace Sharpii Console.WriteLine("ERROR: Unable to open file: {0}", input); Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it."); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_FILE_ERR_01"); - Environment.Exit(0x00003E81); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E81); + } + else + { + Environment.Exit(0x00000003); + } return; } if (edit == false) @@ -252,7 +294,14 @@ namespace Sharpii Console.WriteLine("ERROR: Unable to open folder: {0}", input); Console.WriteLine("Either the folder doesn't exist, or Sharpii doesn't have permission to open it."); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_FOLDER_ERR_01"); - Environment.Exit(0x00003E94); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E94); + } + else + { + Environment.Exit(0x00000016); + } return; } @@ -268,7 +317,14 @@ namespace Sharpii { Console.WriteLine("ERROR: No ID set"); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_NO_ID_01"); - Environment.Exit(0x00003E8E); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E8E); + } + else + { + Environment.Exit(0x00000010); + } return; } id = args[i + 1]; @@ -276,7 +332,14 @@ namespace Sharpii { Console.WriteLine("ERROR: ID too short"); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_SHORT_ID_01"); - Environment.Exit(0x00003E97); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E97); + } + else + { + Environment.Exit(0x00000019); + } return; } id = id.Substring(0, 4); @@ -286,7 +349,14 @@ namespace Sharpii { Console.WriteLine("ERROR: No type set"); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_NO_TYPE_01"); - Environment.Exit(0x00003E98); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E98); + } + else + { + Environment.Exit(0x0000001A); + } return; } lwrid = args[i + 1].ToUpper(); @@ -294,7 +364,14 @@ namespace Sharpii { Console.WriteLine("ERROR: Unknown WAD type: {0}", args[i + 1]); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_UNKNOWN_TYPE_01"); - Environment.Exit(0x00003E99); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E99); + } + else + { + Environment.Exit(0x0000001B); + } return; } break; @@ -303,14 +380,28 @@ namespace Sharpii { Console.WriteLine("ERROR: No type set"); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_NO_TYPE_01"); - Environment.Exit(0x00003E98); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E98); + } + else + { + Environment.Exit(0x0000001A); + } return; } if (!int.TryParse(args[i + 1], out ios)) { Console.WriteLine("Invalid slot {0}...", args[i + 1]); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_INVALID_SLOT_01"); - Environment.Exit(0x00003E8A); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E8A); + } + else + { + Environment.Exit(0x0000000C); + } return; } if (ios < 0 || ios > 255) @@ -336,7 +427,14 @@ namespace Sharpii { Console.WriteLine("ERROR: No sound set"); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_NO_SOUND_01"); - Environment.Exit(0x00003E9A); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E9A); + } + else + { + Environment.Exit(0x0000001C); + } return; } sound = args[i + 1]; @@ -345,7 +443,14 @@ namespace Sharpii Console.WriteLine("ERROR: Unable to find sound wad"); Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it."); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_FILE_ERR_01"); - Environment.Exit(0x00003E81); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E81); + } + else + { + Environment.Exit(0x00000003); + } return; } break; @@ -354,7 +459,14 @@ namespace Sharpii { Console.WriteLine("ERROR: No banner set"); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_NO_BANNER_01"); - Environment.Exit(0x00003E9B); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E9B); + } + else + { + Environment.Exit(0x0000001D); + } return; } banner = args[i + 1]; @@ -363,7 +475,14 @@ namespace Sharpii Console.WriteLine("ERROR: Unable to find banner wad"); Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it."); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_FILE_ERR_01"); - Environment.Exit(0x00003E81); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E81); + } + else + { + Environment.Exit(0x00000003); + } return; } break; @@ -372,7 +491,14 @@ namespace Sharpii { Console.WriteLine("ERROR: No sound set"); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_NO_SOUND_01"); - Environment.Exit(0x00003E9A); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E9A); + } + else + { + Environment.Exit(0x0000001C); + } return; } icon = args[i + 1]; @@ -381,7 +507,14 @@ namespace Sharpii Console.WriteLine("ERROR: Unable to find icon wad"); Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it."); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_FILE_ERR_01"); - Environment.Exit(0x00003E81); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E81); + } + else + { + Environment.Exit(0x00000003); + } return; } break; @@ -390,7 +523,14 @@ namespace Sharpii { Console.WriteLine("ERROR: No dol set"); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_NO_DOL_01"); - Environment.Exit(0x00003E84); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E84); + } + else + { + Environment.Exit(0x00000006); + } return; } app = args[i + 1]; @@ -399,7 +539,14 @@ namespace Sharpii Console.WriteLine("ERROR: Unable to find dol wad/file"); Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it."); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_FILE_ERR_01"); - Environment.Exit(0x00003E81); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E81); + } + else + { + Environment.Exit(0x00000003); + } return; } break; @@ -594,7 +741,14 @@ namespace Sharpii Console.WriteLine(""); Console.WriteLine("Error: SHARPII_NET_CORE_NUSD_MISSING_FILES_01"); ExceptionListRan = 1; - Environment.Exit(0x00003E9D); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E9D); + } + else + { + Environment.Exit(0x0000001F); + } } if (ExceptionListRan == 0) { @@ -602,7 +756,14 @@ namespace Sharpii Console.WriteLine(""); Console.WriteLine("ERROR DETAILS: {0}", ex.Message); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_UNKNOWN_01"); - Environment.Exit(0x00003E82); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E82); + } + else + { + Environment.Exit(0x00000004); + } } } } @@ -620,7 +781,14 @@ namespace Sharpii Console.WriteLine("ERROR: Unable to open file: {0}", input); Console.WriteLine("Either the file doesn't exist, or Sharpii doesn't have permission to open it."); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_FILE_ERR_01"); - Environment.Exit(0x00003E81); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E81); + } + else + { + Environment.Exit(0x00000003); + } return; } @@ -665,7 +833,14 @@ namespace Sharpii Console.WriteLine(""); Console.WriteLine("ERROR DETAILS: {0}", ex.Message); Console.WriteLine("Error: SHARPII_NET_CORE_WAD_UNKNOWN_01"); - Environment.Exit(0x00003E82); + if (OperatingSystem.Windows()) + { + Environment.Exit(0x00003E82); + } + else + { + Environment.Exit(0x00000004); + } return; } }