From aa5998a52e5f7faf28523e7903aebee05a833eb3 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 4 Nov 2021 22:20:52 -0700 Subject: [PATCH] Be consistent with LBA values (fixes #325) --- MPF.Modules/BaseParameters.cs | 50 ++++++---------------- MPF.Modules/DiscImageCreator/Parameters.cs | 3 +- 2 files changed, 13 insertions(+), 40 deletions(-) diff --git a/MPF.Modules/BaseParameters.cs b/MPF.Modules/BaseParameters.cs index 9c542e11..1e135c81 100644 --- a/MPF.Modules/BaseParameters.cs +++ b/MPF.Modules/BaseParameters.cs @@ -308,12 +308,7 @@ namespace MPF.Modules /// Current index /// True if the next item exists, false otherwise protected static bool DoesExist(List parameters, int index) - { - if (index >= parameters.Count) - return false; - - return true; - } + => index < parameters.Count; /// /// Get the Base64 representation of a string @@ -355,14 +350,9 @@ namespace MPF.Modules /// Returns whether a string is a valid drive letter /// /// String value to check - /// True if it's a valid drive letter, false otherwise + /// True if it's a valid drive letter, false otherwise protected static bool IsValidDriveLetter(string parameter) - { - if (!Regex.IsMatch(parameter, @"^[A-Z]:?\\?$")) - return false; - - return true; - } + => Regex.IsMatch(parameter, @"^[A-Z]:?\\?$"); /// /// Returns whether a string is a valid bool @@ -370,9 +360,7 @@ namespace MPF.Modules /// String value to check /// True if it's a valid bool, false otherwise protected static bool IsValidBool(string parameter) - { - return bool.TryParse(parameter, out bool _); - } + => bool.TryParse(parameter, out bool _); /// /// Returns whether a string is a valid byte @@ -462,9 +450,7 @@ namespace MPF.Modules /// Reference to the position in the parts /// True if the parameter was processed successfully or skipped, false otherwise protected bool ProcessFlagParameter(List parts, string flagString, ref int i) - { - return ProcessFlagParameter(parts, null, flagString, ref i); - } + => ProcessFlagParameter(parts, null, flagString, ref i); /// /// Process a flag parameter @@ -499,9 +485,7 @@ namespace MPF.Modules /// True if missing values are allowed, false otherwise /// True if the parameter was processed successfully or skipped, false otherwise protected bool ProcessBooleanParameter(List parts, string flagString, ref int i, bool missingAllowed = false) - { - return ProcessBooleanParameter(parts, null, flagString, ref i, missingAllowed); - } + => ProcessBooleanParameter(parts, null, flagString, ref i, missingAllowed); /// /// Process a boolean parameter @@ -576,9 +560,7 @@ namespace MPF.Modules /// True if missing values are allowed, false otherwise /// SByte value if success, SByte.MinValue if skipped, null on error/returns> protected sbyte? ProcessInt8Parameter(List parts, string flagString, ref int i, bool missingAllowed = false) - { - return ProcessInt8Parameter(parts, null, flagString, ref i, missingAllowed); - } + => ProcessInt8Parameter(parts, null, flagString, ref i, missingAllowed); /// /// Process an sbyte parameter @@ -655,9 +637,7 @@ namespace MPF.Modules /// True if missing values are allowed, false otherwise /// Int16 value if success, Int16.MinValue if skipped, null on error/returns> protected short? ProcessInt16Parameter(List parts, string flagString, ref int i, bool missingAllowed = false) - { - return ProcessInt16Parameter(parts, null, flagString, ref i, missingAllowed); - } + => ProcessInt16Parameter(parts, null, flagString, ref i, missingAllowed); /// /// Process an Int16 parameter @@ -733,9 +713,7 @@ namespace MPF.Modules /// True if missing values are allowed, false otherwise /// Int32 value if success, Int32.MinValue if skipped, null on error/returns> protected int? ProcessInt32Parameter(List parts, string flagString, ref int i, bool missingAllowed = false) - { - return ProcessInt32Parameter(parts, null, flagString, ref i, missingAllowed); - } + => ProcessInt32Parameter(parts, null, flagString, ref i, missingAllowed); /// /// Process an Int32 parameter @@ -811,9 +789,7 @@ namespace MPF.Modules /// True if missing values are allowed, false otherwise /// Int64 value if success, Int64.MinValue if skipped, null on error/returns> protected long? ProcessInt64Parameter(List parts, string flagString, ref int i, bool missingAllowed = false) - { - return ProcessInt64Parameter(parts, null, flagString, ref i, missingAllowed); - } + => ProcessInt64Parameter(parts, null, flagString, ref i, missingAllowed); /// /// Process an Int64 parameter @@ -881,7 +857,7 @@ namespace MPF.Modules } /// - /// Process an Int64 parameter + /// Process an string parameter /// /// List of parts to be referenced /// Flag string, if available @@ -889,9 +865,7 @@ namespace MPF.Modules /// True if missing values are allowed, false otherwise /// String value if possible, string.Empty on missing, null on error protected string ProcessStringParameter(List parts, string flagString, ref int i, bool missingAllowed = false) - { - return ProcessStringParameter(parts, null, flagString, ref i, missingAllowed); - } + => ProcessStringParameter(parts, null, flagString, ref i, missingAllowed); /// /// Process a string parameter diff --git a/MPF.Modules/DiscImageCreator/Parameters.cs b/MPF.Modules/DiscImageCreator/Parameters.cs index 35d67abd..7dee5946 100644 --- a/MPF.Modules/DiscImageCreator/Parameters.cs +++ b/MPF.Modules/DiscImageCreator/Parameters.cs @@ -826,8 +826,7 @@ namespace MPF.Modules.DiscImageCreator if (BaseCommand == CommandStrings.Audio || BaseCommand == CommandStrings.Data) { - if (StartLBAValue != null && StartLBAValue > 0 - && EndLBAValue != null && EndLBAValue > 0) + if (StartLBAValue != null && EndLBAValue != null) { parameters.Add(StartLBAValue.ToString()); parameters.Add(EndLBAValue.ToString());