diff --git a/MPF.Library/Utilities/DumpEnvironment.cs b/MPF.Library/Utilities/DumpEnvironment.cs index 49e85949..ed77b287 100644 --- a/MPF.Library/Utilities/DumpEnvironment.cs +++ b/MPF.Library/Utilities/DumpEnvironment.cs @@ -167,43 +167,6 @@ namespace MPF.Utilities this.Parameters.Type = this.Type; } - /// - /// Cancel an in-progress dumping process - /// - public void CancelDumping() - { - Parameters.KillInternalProgram(); - } - - /// - /// Eject the disc using DiscImageCreator - /// - public async void EjectDisc() - { - // Validate that the path is configured - if (string.IsNullOrWhiteSpace(Options.DiscImageCreatorPath)) - return; - - // Validate that the required program exists - if (!File.Exists(Options.DiscImageCreatorPath)) - return; - - CancelDumping(); - - // Validate we're not trying to eject a non-optical - if (Drive.InternalDriveType != InternalDriveType.Optical) - return; - - var parameters = new DiscImageCreator.Parameters(string.Empty) - { - BaseCommand = DiscImageCreator.Command.Eject, - DriveLetter = Drive.Letter.ToString(), - ExecutablePath = Options.DiscImageCreatorPath, - }; - - await ExecuteInternalProgram(parameters); - } - /// /// Ensures that all required output files have been created /// @@ -320,6 +283,47 @@ namespace MPF.Utilities return (directory, filename); } + #endregion + + #region Dumping + + /// + /// Cancel an in-progress dumping process + /// + public void CancelDumping() + { + Parameters.KillInternalProgram(); + } + + /// + /// Eject the disc using DiscImageCreator + /// + public async void EjectDisc() + { + // Validate that the path is configured + if (string.IsNullOrWhiteSpace(Options.DiscImageCreatorPath)) + return; + + // Validate that the required program exists + if (!File.Exists(Options.DiscImageCreatorPath)) + return; + + CancelDumping(); + + // Validate we're not trying to eject a non-optical + if (Drive.InternalDriveType != InternalDriveType.Optical) + return; + + var parameters = new DiscImageCreator.Parameters(string.Empty) + { + BaseCommand = DiscImageCreator.Command.Eject, + DriveLetter = Drive.Letter.ToString(), + ExecutablePath = Options.DiscImageCreatorPath, + }; + + await ExecuteInternalProgram(parameters); + } + /// /// Reset the current drive using DiscImageCreator /// @@ -453,10 +457,6 @@ namespace MPF.Utilities return Result.Success(); } - #endregion - - #region Internal for Testing Purposes - /// /// Checks if the parameters are valid /// @@ -473,10 +473,6 @@ namespace MPF.Utilities return parametersValid && floppyValid && removableDiskValid; } - #endregion - - #region Private Helpers - /// /// Run any additional tools given a DumpEnvironment /// @@ -948,7 +944,12 @@ namespace MPF.Utilities AddIfExists(output, Template.DiscNumberField, info.CommonDiscInfo.DiscNumberLetter, 1); AddIfExists(output, Template.DiscTitleField, info.CommonDiscInfo.DiscTitle, 1); AddIfExists(output, Template.SystemField, info.CommonDiscInfo.System.LongName(), 1); - AddIfExists(output, Template.MediaTypeField, GetFixedMediaType(info.CommonDiscInfo.Media, info.SizeAndChecksums.Layerbreak), 1); + AddIfExists(output, Template.MediaTypeField, GetFixedMediaType( + info.CommonDiscInfo.Media, + info.SizeAndChecksums.Layerbreak, + info.SizeAndChecksums.Layerbreak2, + info.SizeAndChecksums.Layerbreak3), + 1); AddIfExists(output, Template.CategoryField, info.CommonDiscInfo.Category.LongName(), 1); AddIfExists(output, Template.MatchingIDsField, info.MatchedIDs, 1); AddIfExists(output, Template.RegionField, info.CommonDiscInfo.Region.LongName(), 1); @@ -1108,7 +1109,7 @@ namespace MPF.Utilities // Make sure there aren't any instances of two blank lines in a row string last = null; - for (int i = 0; i < output.Count; ) + for (int i = 0; i < output.Count;) { if (output[i] == last && string.IsNullOrWhiteSpace(last)) { @@ -1130,81 +1131,15 @@ namespace MPF.Utilities } } - /// - /// Add the properly formatted key and value, if possible - /// - /// Output list - /// Name of the output key to write - /// Name of the output value to write - /// Number of tabs to indent the line - private void AddIfExists(List output, string key, string value, int indent) - { - // If there's no valid value to write - if (value == null) - return; - - string prefix = ""; - for (int i = 0; i < indent; i++) - prefix += "\t"; - - // If the value contains a newline - value = value.Replace("\r\n", "\n"); - if (value.Contains("\n")) - { - output.Add(prefix + key + ":"); output.Add(""); - string[] values = value.Split('\n'); - foreach (string val in values) - output.Add(val); - - output.Add(""); - } - - // For all regular values - else - { - output.Add(prefix + key + ": " + value); - } - } - - /// - /// Add the properly formatted key and value, if possible - /// - /// Output list - /// Name of the output key to write - /// Name of the output value to write - /// Number of tabs to indent the line - private void AddIfExists(List output, string key, string[] value, int indent) - { - // If there's no valid value to write - if (value == null || value.Length == 0) - return; - - AddIfExists(output, key, string.Join(", ", value), indent); - } - - /// - /// Add the properly formatted key and value, if possible - /// - /// Output list - /// Name of the output key to write - /// Name of the output value to write - /// Number of tabs to indent the line - private void AddIfExists(List output, string key, List value, int indent) - { - // If there's no valid value to write - if (value == null || value.Count() == 0) - return; - - AddIfExists(output, key, string.Join(", ", value.Select(o => o.ToString())), indent); - } - /// /// Get the adjusted name of the media baed on layers, if applicable /// /// MediaType to get the proper name for - /// Layerbreak value, as applicable + /// First layerbreak value, as applicable + /// Second layerbreak value, as applicable + /// Third ayerbreak value, as applicable /// String representation of the media, including layer specification - private string GetFixedMediaType(MediaType? mediaType, long layerbreak) + private string GetFixedMediaType(MediaType? mediaType, long layerbreak, long layerbreak2, long layerbreak3) { switch (mediaType) { @@ -1214,6 +1149,7 @@ namespace MPF.Utilities else return $"{mediaType.LongName()}-5"; + // TODO: Figure out what the addtional layerbreaks indicate case MediaType.BluRay: if (layerbreak != default) return $"{mediaType.LongName()}-50"; @@ -1324,7 +1260,7 @@ namespace MPF.Utilities #endregion - #region Information Extraction Methods + #region Information Extraction /// /// Get the current copy protection scheme, if possible @@ -1368,5 +1304,77 @@ namespace MPF.Utilities } #endregion + + #region Information Formatting + + /// + /// Add the properly formatted key and value, if possible + /// + /// Output list + /// Name of the output key to write + /// Name of the output value to write + /// Number of tabs to indent the line + private void AddIfExists(List output, string key, string value, int indent) + { + // If there's no valid value to write + if (value == null) + return; + + string prefix = ""; + for (int i = 0; i < indent; i++) + prefix += "\t"; + + // If the value contains a newline + value = value.Replace("\r\n", "\n"); + if (value.Contains("\n")) + { + output.Add(prefix + key + ":"); output.Add(""); + string[] values = value.Split('\n'); + foreach (string val in values) + output.Add(val); + + output.Add(""); + } + + // For all regular values + else + { + output.Add(prefix + key + ": " + value); + } + } + + /// + /// Add the properly formatted key and value, if possible + /// + /// Output list + /// Name of the output key to write + /// Name of the output value to write + /// Number of tabs to indent the line + private void AddIfExists(List output, string key, string[] value, int indent) + { + // If there's no valid value to write + if (value == null || value.Length == 0) + return; + + AddIfExists(output, key, string.Join(", ", value), indent); + } + + /// + /// Add the properly formatted key and value, if possible + /// + /// Output list + /// Name of the output key to write + /// Name of the output value to write + /// Number of tabs to indent the line + private void AddIfExists(List output, string key, List value, int indent) + { + // If there's no valid value to write + if (value == null || value.Count() == 0) + return; + + AddIfExists(output, key, string.Join(", ", value.Select(o => o.ToString())), indent); + } + + #endregion } }