diff --git a/MPF.Core/Data/Drive.cs b/MPF.Core/Data/Drive.cs index e2bda944..54d4068a 100644 --- a/MPF.Core/Data/Drive.cs +++ b/MPF.Core/Data/Drive.cs @@ -70,7 +70,9 @@ namespace MPF.Core.Data return volumeLabel; if (!string.IsNullOrEmpty(this.VolumeLabel)) + { volumeLabel = this.VolumeLabel; + } else { // No Volume Label found, fallback to something sensible diff --git a/MPF.Core/InfoTool.cs b/MPF.Core/InfoTool.cs index d9dcbab7..fcd8b24b 100644 --- a/MPF.Core/InfoTool.cs +++ b/MPF.Core/InfoTool.cs @@ -1876,8 +1876,10 @@ namespace MPF.Core if (string.IsNullOrEmpty(path)) return string.Empty; - // Remove quotes from path + // Remove quotes and angle brackets from path path = path!.Replace("\"", string.Empty); + path = path!.Replace("<", string.Empty); + path = path!.Replace(">", string.Empty); // Try getting the combined path and returning that directly string fullPath = getFullPath ? Path.GetFullPath(path) : path; diff --git a/MPF.Core/UI/ViewModels/MainViewModel.cs b/MPF.Core/UI/ViewModels/MainViewModel.cs index e24448b5..3c4a42a5 100644 --- a/MPF.Core/UI/ViewModels/MainViewModel.cs +++ b/MPF.Core/UI/ViewModels/MainViewModel.cs @@ -148,6 +148,7 @@ namespace MPF.Core.UI.ViewModels /// /// Currently provided output path + /// Not guaranteed to be a valid path /// public string OutputPath { @@ -1190,7 +1191,7 @@ namespace MPF.Core.UI.ViewModels { return new DumpEnvironment( this.Options, - this.OutputPath, + EvaluateOutputPath(this.OutputPath), this.CurrentDrive, this.CurrentSystem, this.CurrentMediaType, @@ -1299,6 +1300,49 @@ namespace MPF.Core.UI.ViewModels } } + /// + /// Replaces %-delimited variables inside a path string with their values + /// + /// Path to be evaluated + /// String with %-delimited variables evaluated + public string EvaluateOutputPath(string outputPath) + { + string systemLong = this._currentSystem.LongName() ?? "Unknown System"; + if (string.IsNullOrEmpty(systemLong)) + systemLong = "Unknown System"; + string systemShort = this._currentSystem.ShortName() ?? "unknown"; + if (string.IsNullOrEmpty(systemShort)) + systemShort = "unknown"; + string mediaLong = this._currentMediaType.LongName() ?? "Unknown Media"; + if (string.IsNullOrEmpty(mediaLong)) + mediaLong = "Unknown Media"; + string program = this._currentProgram.ToString() ?? "Unknown Program"; + if (string.IsNullOrEmpty(program)) + program = "Unknown Program"; + string programShort = program == "DiscImageCreator" ? "DIC" : program; + if (string.IsNullOrEmpty(programShort)) + programShort = "Unknown Program"; + string label = this._currentDrive?.FormattedVolumeLabel ?? "track"; + if (string.IsNullOrEmpty(label)) + label = "track"; + string date = DateTime.Today.ToString("yyyyMMdd"); + if (string.IsNullOrEmpty(date)) + date = "UNKNOWN"; + string datetime = DateTime.Now.ToString("yyyyMMdd-HHmmss"); + if (string.IsNullOrEmpty(datetime)) + datetime = "UNKNOWN"; + + return outputPath + .Replace("%SYSTEM%", systemLong) + .Replace("%SYS%", systemShort) + .Replace("%MEDIA%", mediaLong) + .Replace("%PROGRAM%", program) + .Replace("%PROG%", programShort) + .Replace("%LABEL%", label) + .Replace("%DATE%", date) + .Replace("%DATETIME%", datetime); + } + /// /// Get the default output directory name from the currently selected drive /// diff --git a/MPF.UI.Core/Windows/OptionsWindow.xaml b/MPF.UI.Core/Windows/OptionsWindow.xaml index c043a103..2f0dbbde 100644 --- a/MPF.UI.Core/Windows/OptionsWindow.xaml +++ b/MPF.UI.Core/Windows/OptionsWindow.xaml @@ -181,7 +181,8 @@