diff --git a/CHANGELIST.md b/CHANGELIST.md index a5d0d071..931ca910 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -2,6 +2,7 @@ - Split InfoTool into 2 classes - Add path variants for PlayStation info +- Convert Drive to use paths internally ### 2.7.2 (2023-10-17) diff --git a/MPF.Core/Data/Drive.cs b/MPF.Core/Data/Drive.cs index 34633140..04000057 100644 --- a/MPF.Core/Data/Drive.cs +++ b/MPF.Core/Data/Drive.cs @@ -95,11 +95,6 @@ namespace MPF.Core.Data } } - /// - /// Windows drive letter - /// - public char Letter => this.Name == null || this.Name.Length == 0 ? '\0' : this.Name[0]; - #endregion /// @@ -188,7 +183,7 @@ namespace MPF.Core.Data public static List CreateListOfDrives(bool ignoreFixedDrives) { var drives = GetDriveList(ignoreFixedDrives); - drives = drives.OrderBy(i => i == null ? '\0' : i.Letter).ToList(); + drives = drives.OrderBy(i => i == null ? "\0" : i.Name).ToList(); return drives; } @@ -285,10 +280,8 @@ namespace MPF.Core.Data /// public RedumpSystem? GetRedumpSystem(RedumpSystem? defaultValue) { - string drivePath = $"{this.Letter}:\\"; - // If we can't read the media in that drive, we can't do anything - if (!Directory.Exists(drivePath)) + if (!Directory.Exists(this.Name)) return defaultValue; // We're going to assume for floppies, HDDs, and removable drives @@ -307,7 +300,7 @@ namespace MPF.Core.Data // Bandai Playdia Quick Interactive System try { - List files = Directory.EnumerateFiles(drivePath, "*", SearchOption.TopDirectoryOnly).ToList(); + List files = Directory.EnumerateFiles(this.Name, "*", SearchOption.TopDirectoryOnly).ToList(); if (files.Any(f => f.EndsWith(".AJS", StringComparison.OrdinalIgnoreCase)) && files.Any(f => f.EndsWith(".GLB", StringComparison.OrdinalIgnoreCase))) @@ -318,7 +311,7 @@ namespace MPF.Core.Data catch { } // Mattel Fisher-Price iXL - if (File.Exists(Path.Combine(drivePath, "iXL", "iXLUpdater.exe"))) + if (File.Exists(Path.Combine(this.Name, "iXL", "iXLUpdater.exe"))) { return RedumpSystem.MattelFisherPriceiXL; } @@ -326,8 +319,8 @@ namespace MPF.Core.Data // Microsoft Xbox 360 try { - if (Directory.Exists(Path.Combine(drivePath, "$SystemUpdate")) - && Directory.EnumerateFiles(Path.Combine(drivePath, "$SystemUpdate")).Any() + if (Directory.Exists(Path.Combine(this.Name, "$SystemUpdate")) + && Directory.EnumerateFiles(Path.Combine(this.Name, "$SystemUpdate")).Any() && this.TotalSize <= 500_000_000) { return RedumpSystem.MicrosoftXbox360; @@ -338,8 +331,8 @@ namespace MPF.Core.Data // Microsoft Xbox One try { - if (Directory.Exists(Path.Combine(drivePath, "MSXC")) - && Directory.EnumerateFiles(Path.Combine(drivePath, "MSXC")).Any()) + if (Directory.Exists(Path.Combine(this.Name, "MSXC")) + && Directory.EnumerateFiles(Path.Combine(this.Name, "MSXC")).Any()) { return RedumpSystem.MicrosoftXboxOne; } @@ -347,35 +340,23 @@ namespace MPF.Core.Data catch { } // Sega Dreamcast - if (File.Exists(Path.Combine(drivePath, "IP.BIN"))) + if (File.Exists(Path.Combine(this.Name, "IP.BIN"))) { return RedumpSystem.SegaDreamcast; } // Sega Mega-CD / Sega-CD - if (File.Exists(Path.Combine(drivePath, "_BOOT", "IP.BIN")) - || File.Exists(Path.Combine(drivePath, "_BOOT", "SP.BIN")) - || File.Exists(Path.Combine(drivePath, "_BOOT", "SP_AS.BIN")) - || File.Exists(Path.Combine(drivePath, "FILESYSTEM.BIN"))) + if (File.Exists(Path.Combine(this.Name, "_BOOT", "IP.BIN")) + || File.Exists(Path.Combine(this.Name, "_BOOT", "SP.BIN")) + || File.Exists(Path.Combine(this.Name, "_BOOT", "SP_AS.BIN")) + || File.Exists(Path.Combine(this.Name, "FILESYSTEM.BIN"))) { return RedumpSystem.SegaMegaCDSegaCD; } - // Sega Saturn - try - { - var sector = ReadSector(0); - if (sector != null) - { - if (sector.StartsWith(Interface.SaturnSectorZeroStart)) - return RedumpSystem.SegaSaturn; - } - } - catch { } - // Sony PlayStation and Sony PlayStation 2 - string psxExePath = Path.Combine(drivePath, "PSX.EXE"); - string systemCnfPath = Path.Combine(drivePath, "SYSTEM.CNF"); + string psxExePath = Path.Combine(this.Name, "PSX.EXE"); + string systemCnfPath = Path.Combine(this.Name, "SYSTEM.CNF"); if (File.Exists(systemCnfPath)) { // Check for either BOOT or BOOT2 @@ -393,9 +374,9 @@ namespace MPF.Core.Data // Sony PlayStation 3 try { - if (Directory.Exists(Path.Combine(drivePath, "PS3_GAME")) - || Directory.Exists(Path.Combine(drivePath, "PS3_UPDATE")) - || File.Exists(Path.Combine(drivePath, "PS3_DISC.SFB"))) + if (Directory.Exists(Path.Combine(this.Name, "PS3_GAME")) + || Directory.Exists(Path.Combine(this.Name, "PS3_UPDATE")) + || File.Exists(Path.Combine(this.Name, "PS3_DISC.SFB"))) { return RedumpSystem.SonyPlayStation3; } @@ -414,13 +395,13 @@ namespace MPF.Core.Data // Is used as an on-disc update for the base game app without needing to get update from the internet. // "/addcont/GAME_SERIAL/CONTENT_ID/ac.pkg" can be found in Redump entry 97619. // Originally on disc as "/addcont/CUSA00288/FFXIVEXPS400001A/ac.pkg". - if (File.Exists(Path.Combine(drivePath, "PS4", "UPDATE", "PS4UPDATE.PUP"))) + if (File.Exists(Path.Combine(this.Name, "PS4", "UPDATE", "PS4UPDATE.PUP"))) { return RedumpSystem.SonyPlayStation4; } // V.Tech V.Flash / V.Smile Pro - if (File.Exists(Path.Combine(drivePath, "0SYSTEM"))) + if (File.Exists(Path.Combine(this.Name, "0SYSTEM"))) { return RedumpSystem.VTechVFlashVSmilePro; } @@ -430,7 +411,7 @@ namespace MPF.Core.Data #region Computers // Sharp X68000 - if (File.Exists(Path.Combine(drivePath, "COMMAND.X"))) + if (File.Exists(Path.Combine(this.Name, "COMMAND.X"))) { return RedumpSystem.SharpX68000; } @@ -440,7 +421,7 @@ namespace MPF.Core.Data #region Video Formats // BD-Video - if (Directory.Exists(Path.Combine(drivePath, "BDMV"))) + if (Directory.Exists(Path.Combine(this.Name, "BDMV"))) { // Technically BD-Audio has this as well, but it's hard to split that out right now return RedumpSystem.BDVideo; @@ -449,14 +430,14 @@ namespace MPF.Core.Data // DVD-Audio and DVD-Video try { - if (Directory.Exists(Path.Combine(drivePath, "AUDIO_TS")) - && Directory.EnumerateFiles(Path.Combine(drivePath, "AUDIO_TS")).Any()) + if (Directory.Exists(Path.Combine(this.Name, "AUDIO_TS")) + && Directory.EnumerateFiles(Path.Combine(this.Name, "AUDIO_TS")).Any()) { return RedumpSystem.DVDAudio; } - else if (Directory.Exists(Path.Combine(drivePath, "VIDEO_TS")) - && Directory.EnumerateFiles(Path.Combine(drivePath, "VIDEO_TS")).Any()) + else if (Directory.Exists(Path.Combine(this.Name, "VIDEO_TS")) + && Directory.EnumerateFiles(Path.Combine(this.Name, "VIDEO_TS")).Any()) { return RedumpSystem.DVDVideo; } @@ -466,8 +447,8 @@ namespace MPF.Core.Data // HD-DVD-Video try { - if (Directory.Exists(Path.Combine(drivePath, "HVDVD_TS")) - && Directory.EnumerateFiles(Path.Combine(drivePath, "HVDVD_TS")).Any()) + if (Directory.Exists(Path.Combine(this.Name, "HVDVD_TS")) + && Directory.EnumerateFiles(Path.Combine(this.Name, "HVDVD_TS")).Any()) { return RedumpSystem.HDDVDVideo; } @@ -477,8 +458,8 @@ namespace MPF.Core.Data // VCD try { - if (Directory.Exists(Path.Combine(drivePath, "VCD")) - && Directory.EnumerateFiles(Path.Combine(drivePath, "VCD")).Any()) + if (Directory.Exists(Path.Combine(this.Name, "VCD")) + && Directory.EnumerateFiles(Path.Combine(this.Name, "VCD")).Any()) { return RedumpSystem.VideoCD; } @@ -542,56 +523,6 @@ namespace MPF.Core.Data return null; } - /// - /// Read a sector with a specified size from the drive - /// - /// Sector number, non-negative - /// Size of a sector in bytes - /// Byte array representing the sector, null on error -#if NET48 - public byte[] ReadSector(long num, int size = 2048) -#else - public byte[]? ReadSector(long num, int size = 2048) -#endif - { - // Missing drive leter is not supported - if (string.IsNullOrEmpty(this.Name)) - return null; - - // We don't support negative sectors - if (num < 0) - return null; - - // Wrap the following in case of device access errors -#if NET48 - Stream fs = null; -#else - Stream? fs = null; -#endif - try - { - // Open the drive as a device - fs = File.OpenRead($"\\\\?\\{this.Letter}:"); - - // Seek to the start of the sector, if possible - long start = num * size; - fs.Seek(start, SeekOrigin.Begin); - - // Read and return the sector - byte[] buffer = new byte[size]; - fs.Read(buffer, 0, size); - return buffer; - } - catch - { - return null; - } - finally - { - fs?.Dispose(); - } - } - /// /// Refresh the current drive information based on path /// @@ -655,7 +586,7 @@ namespace MPF.Core.Data if (mediaType != null && ((mediaType > 0 && mediaType < 11) || (mediaType > 12 && mediaType < 22))) { char devId = (properties["Caption"].Value as string ?? string.Empty)[0]; - drives.ForEach(d => { if (d?.Letter == devId) { d.InternalDriveType = Data.InternalDriveType.Floppy; } }); + drives.ForEach(d => { if (d?.Name != null && d.Name[0] == devId) { d.InternalDriveType = Data.InternalDriveType.Floppy; } }); } } } diff --git a/MPF.Core/DumpEnvironment.cs b/MPF.Core/DumpEnvironment.cs index 8a0695a0..da3851fb 100644 --- a/MPF.Core/DumpEnvironment.cs +++ b/MPF.Core/DumpEnvironment.cs @@ -287,31 +287,31 @@ namespace MPF.Core switch (InternalProgram) { case InternalProgram.Aaru: - Parameters = new Modules.Aaru.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options); + Parameters = new Modules.Aaru.Parameters(System, Type, Drive.Name, OutputPath, driveSpeed, Options); break; case InternalProgram.DiscImageCreator: - Parameters = new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options); + Parameters = new Modules.DiscImageCreator.Parameters(System, Type, Drive.Name, OutputPath, driveSpeed, Options); break; case InternalProgram.Redumper: - Parameters = new Modules.Redumper.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options); + Parameters = new Modules.Redumper.Parameters(System, Type, Drive.Name, OutputPath, driveSpeed, Options); break; // This should never happen, but it needs a fallback default: - Parameters = new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options); + Parameters = new Modules.DiscImageCreator.Parameters(System, Type, Drive.Name, OutputPath, driveSpeed, Options); break; } #else Parameters = InternalProgram switch { - InternalProgram.Aaru => new Modules.Aaru.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options), - InternalProgram.DiscImageCreator => new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options), - InternalProgram.Redumper => new Modules.Redumper.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options), + InternalProgram.Aaru => new Modules.Aaru.Parameters(System, Type, Drive.Name, OutputPath, driveSpeed, Options), + InternalProgram.DiscImageCreator => new Modules.DiscImageCreator.Parameters(System, Type, Drive.Name, OutputPath, driveSpeed, Options), + InternalProgram.Redumper => new Modules.Redumper.Parameters(System, Type, Drive.Name, OutputPath, driveSpeed, Options), // This should never happen, but it needs a fallback - _ => new Modules.DiscImageCreator.Parameters(System, Type, Drive.Letter, OutputPath, driveSpeed, Options), + _ => new Modules.DiscImageCreator.Parameters(System, Type, Drive.Name, OutputPath, driveSpeed, Options), }; #endif @@ -457,14 +457,14 @@ namespace MPF.Core // Eject the disc automatically if configured to if (Options.EjectAfterDump == true) { - resultProgress?.Report(Result.Success($"Ejecting disc in drive {Drive?.Letter}")); + resultProgress?.Report(Result.Success($"Ejecting disc in drive {Drive?.Name}")); await EjectDisc(); } // Reset the drive automatically if configured to if (InternalProgram == InternalProgram.DiscImageCreator && Options.DICResetDriveAfterDump) { - resultProgress?.Report(Result.Success($"Resetting drive {Drive?.Letter}")); + resultProgress?.Report(Result.Success($"Resetting drive {Drive?.Name}")); await ResetDrive(); } @@ -684,7 +684,7 @@ namespace MPF.Core OutputPath = InfoTool.NormalizeOutputPaths(OutputPath, true); // Validate that the output path isn't on the dumping drive - if (Drive != null && OutputPath[0] == Drive.Letter) + if (Drive?.Name != null && !OutputPath.StartsWith(Drive.Name)) return Result.Failure("Error! Cannot output to same drive that is being dumped!"); // Validate that the required program exists @@ -693,7 +693,7 @@ namespace MPF.Core // Validate that the dumping drive doesn't contain the executable string fullExecutablePath = Path.GetFullPath(Parameters.ExecutablePath); - if (Drive != null && fullExecutablePath[0] == Drive.Letter) + if (Drive?.Name != null && fullExecutablePath.StartsWith(Drive.Name)) return Result.Failure("Error! Cannot dump same drive that executable resides on!"); // Validate that the current configuration is supported @@ -741,7 +741,7 @@ namespace MPF.Core var parameters = new Modules.DiscImageCreator.Parameters(string.Empty) { BaseCommand = command, - DriveLetter = Drive.Letter.ToString(), + DrivePath = Drive.Name, ExecutablePath = Options.DiscImageCreatorPath, }; diff --git a/MPF.Core/InfoTool.cs b/MPF.Core/InfoTool.cs index f7fe0008..40617ea0 100644 --- a/MPF.Core/InfoTool.cs +++ b/MPF.Core/InfoTool.cs @@ -19,8 +19,6 @@ using SabreTools.Models.PIC; using SabreTools.RedumpLib.Data; using Formatting = Newtonsoft.Json.Formatting; -#pragma warning disable IDE0051 // Remove unused private members - namespace MPF.Core { public static class InfoTool @@ -103,7 +101,7 @@ namespace MPF.Core /// Drive object representing the current drive /// Anti-modchip existence if possible, false on error internal static async Task GetAntiModchipDetected(Drive drive) - => await Protection.GetPlayStationAntiModchipDetected($"{drive.Letter}:\\"); + => await Protection.GetPlayStationAntiModchipDetected(drive.Name); /// /// Get the current detected copy protection(s), if possible @@ -118,9 +116,9 @@ namespace MPF.Core internal static async Task<(string?, Dictionary>?)> GetCopyProtection(Drive? drive, Data.Options options, IProgress? progress = null) #endif { - if (options.ScanForProtection && drive != null) + if (options.ScanForProtection && drive?.Name != null) { - (var protection, _) = await Protection.RunProtectionScanOnPath($"{drive.Letter}:\\", options, progress); + (var protection, _) = await Protection.RunProtectionScanOnPath(drive.Name, options, progress); return (Protection.FormatProtections(protection), protection); } @@ -389,7 +387,7 @@ namespace MPF.Core #if NET48 internal static bool GetISOHashValues(string hashData, out long size, out string crc32, out string md5, out string sha1) #else - internal static bool GetISOHashValues(string hashData, out long size, out string? crc32, out string? md5, out string? sha1) + internal static bool GetISOHashValues(string? hashData, out long size, out string? crc32, out string? md5, out string? sha1) #endif { size = -1; crc32 = null; md5 = null; sha1 = null; diff --git a/MPF.Core/Modules/Aaru/Parameters.cs b/MPF.Core/Modules/Aaru/Parameters.cs index b95d2fba..a022c788 100644 --- a/MPF.Core/Modules/Aaru/Parameters.cs +++ b/MPF.Core/Modules/Aaru/Parameters.cs @@ -264,8 +264,12 @@ namespace MPF.Core.Modules.Aaru #endif /// - public Parameters(RedumpSystem? system, MediaType? type, char driveLetter, string filename, int? driveSpeed, Options options) - : base(system, type, driveLetter, filename, driveSpeed, options) +#if NET48 + public Parameters(RedumpSystem? system, MediaType? type, string drivePath, string filename, int? driveSpeed, Options options) +#else + public Parameters(RedumpSystem? system, MediaType? type, string? drivePath, string filename, int? driveSpeed, Options options) +#endif + : base(system, type, drivePath, filename, driveSpeed, options) { } @@ -480,7 +484,7 @@ namespace MPF.Core.Modules.Aaru break; case RedumpSystem.KonamiPython2: - if (InfoTool.GetPlayStationExecutableInfo(drive?.Letter, out var pythonTwoSerial, out Region? pythonTwoRegion, out var pythonTwoDate)) + if (InfoTool.GetPlayStationExecutableInfo(drive?.Name, out var pythonTwoSerial, out Region? pythonTwoRegion, out var pythonTwoDate)) { // Ensure internal serial is pulled from local data #if NET48 @@ -493,9 +497,9 @@ namespace MPF.Core.Modules.Aaru } #if NET48 - info.VersionAndEditions.Version = InfoTool.GetPlayStation2Version(drive?.Letter) ?? string.Empty; + info.VersionAndEditions.Version = InfoTool.GetPlayStation2Version(drive?.Name) ?? string.Empty; #else - info.VersionAndEditions!.Version = InfoTool.GetPlayStation2Version(drive?.Letter) ?? string.Empty; + info.VersionAndEditions!.Version = InfoTool.GetPlayStation2Version(drive?.Name) ?? string.Empty; #endif break; @@ -563,7 +567,7 @@ namespace MPF.Core.Modules.Aaru break; case RedumpSystem.SonyPlayStation: - if (InfoTool.GetPlayStationExecutableInfo(drive?.Letter, out var playstationSerial, out Region? playstationRegion, out var playstationDate)) + if (InfoTool.GetPlayStationExecutableInfo(drive?.Name, out var playstationSerial, out Region? playstationRegion, out var playstationDate)) { // Ensure internal serial is pulled from local data #if NET48 @@ -578,7 +582,7 @@ namespace MPF.Core.Modules.Aaru break; case RedumpSystem.SonyPlayStation2: - if (InfoTool.GetPlayStationExecutableInfo(drive?.Letter, out var playstationTwoSerial, out Region? playstationTwoRegion, out var playstationTwoDate)) + if (InfoTool.GetPlayStationExecutableInfo(drive?.Name, out var playstationTwoSerial, out Region? playstationTwoRegion, out var playstationTwoDate)) { // Ensure internal serial is pulled from local data #if NET48 @@ -591,39 +595,39 @@ namespace MPF.Core.Modules.Aaru } #if NET48 - info.VersionAndEditions.Version = InfoTool.GetPlayStation2Version(drive?.Letter) ?? string.Empty; + info.VersionAndEditions.Version = InfoTool.GetPlayStation2Version(drive?.Name) ?? string.Empty; #else - info.VersionAndEditions!.Version = InfoTool.GetPlayStation2Version(drive?.Letter) ?? string.Empty; + info.VersionAndEditions!.Version = InfoTool.GetPlayStation2Version(drive?.Name) ?? string.Empty; #endif break; case RedumpSystem.SonyPlayStation3: #if NET48 - info.VersionAndEditions.Version = InfoTool.GetPlayStation3Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation3Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions.Version = InfoTool.GetPlayStation3Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation3Serial(drive?.Name) ?? string.Empty; #else - info.VersionAndEditions!.Version = InfoTool.GetPlayStation3Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation3Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions!.Version = InfoTool.GetPlayStation3Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation3Serial(drive?.Name) ?? string.Empty; #endif break; case RedumpSystem.SonyPlayStation4: #if NET48 - info.VersionAndEditions.Version = InfoTool.GetPlayStation4Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation4Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions.Version = InfoTool.GetPlayStation4Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation4Serial(drive?.Name) ?? string.Empty; #else - info.VersionAndEditions!.Version = InfoTool.GetPlayStation4Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation4Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions!.Version = InfoTool.GetPlayStation4Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation4Serial(drive?.Name) ?? string.Empty; #endif break; case RedumpSystem.SonyPlayStation5: #if NET48 - info.VersionAndEditions.Version = InfoTool.GetPlayStation5Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation5Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions.Version = InfoTool.GetPlayStation5Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation5Serial(drive?.Name) ?? string.Empty; #else - info.VersionAndEditions!.Version = InfoTool.GetPlayStation5Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation5Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions!.Version = InfoTool.GetPlayStation5Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation5Serial(drive?.Name) ?? string.Empty; #endif break; } @@ -1778,11 +1782,15 @@ namespace MPF.Core.Modules.Aaru } /// - protected override void SetDefaultParameters(char driveLetter, string filename, int? driveSpeed, Options options) +#if NET48 + protected override void SetDefaultParameters(string drivePath, string filename, int? driveSpeed, Options options) +#else + protected override void SetDefaultParameters(string? drivePath, string filename, int? driveSpeed, Options options) +#endif { BaseCommand = $"{CommandStrings.MediaPrefixLong} {CommandStrings.MediaDump}"; - InputValue = $"{driveLetter}:"; + InputValue = drivePath; OutputValue = filename; if (driveSpeed != null) diff --git a/MPF.Core/Modules/BaseParameters.cs b/MPF.Core/Modules/BaseParameters.cs index 00b826f1..e17c5be9 100644 --- a/MPF.Core/Modules/BaseParameters.cs +++ b/MPF.Core/Modules/BaseParameters.cs @@ -161,15 +161,19 @@ namespace MPF.Core.Modules /// /// RedumpSystem value to use /// MediaType value to use - /// Drive letter to use + /// Drive path to use /// Filename to use /// Drive speed to use /// Options object containing all settings that may be used for setting parameters - public BaseParameters(RedumpSystem? system, MediaType? type, char driveLetter, string filename, int? driveSpeed, Options options) +#if NET48 + public BaseParameters(RedumpSystem? system, MediaType? type, string drivePath, string filename, int? driveSpeed, Options options) +#else + public BaseParameters(RedumpSystem? system, MediaType? type, string? drivePath, string filename, int? driveSpeed, Options options) +#endif { this.System = system; this.Type = type; - SetDefaultParameters(driveLetter, filename, driveSpeed, options); + SetDefaultParameters(drivePath, filename, driveSpeed, options); } #region Abstract Methods @@ -284,11 +288,15 @@ namespace MPF.Core.Modules /// /// Set default parameters for a given system and media type /// - /// Drive letter to use + /// Drive path to use /// Filename to use /// Drive speed to use /// Options object containing all settings that may be used for setting parameters - protected virtual void SetDefaultParameters(char driveLetter, string filename, int? driveSpeed, Options options) { } +#if NET48 + protected virtual void SetDefaultParameters(string drivePath, string filename, int? driveSpeed, Options options) { } +#else + protected virtual void SetDefaultParameters(string? drivePath, string filename, int? driveSpeed, Options options) { } +#endif /// /// Scan a possible parameter string and populate whatever possible diff --git a/MPF.Core/Modules/CleanRIp/Parameters.cs b/MPF.Core/Modules/CleanRIp/Parameters.cs index 3ffe42d8..6a33db83 100644 --- a/MPF.Core/Modules/CleanRIp/Parameters.cs +++ b/MPF.Core/Modules/CleanRIp/Parameters.cs @@ -30,8 +30,12 @@ namespace MPF.Core.Modules.CleanRip #endif /// - public Parameters(RedumpSystem? system, MediaType? type, char driveLetter, string filename, int? driveSpeed, Options options) - : base(system, type, driveLetter, filename, driveSpeed, options) +#if NET48 + public Parameters(RedumpSystem? system, MediaType? type, string drivePath, string filename, int? driveSpeed, Options options) +#else + public Parameters(RedumpSystem? system, MediaType? type, string? drivePath, string filename, int? driveSpeed, Options options) +#endif + : base(system, type, drivePath, filename, driveSpeed, options) { } diff --git a/MPF.Core/Modules/DiscImageCreator/Parameters.cs b/MPF.Core/Modules/DiscImageCreator/Parameters.cs index a7f47ff0..4aed4ece 100644 --- a/MPF.Core/Modules/DiscImageCreator/Parameters.cs +++ b/MPF.Core/Modules/DiscImageCreator/Parameters.cs @@ -19,9 +19,9 @@ namespace MPF.Core.Modules.DiscImageCreator /// #if NET48 - public override string InputPath => DriveLetter; + public override string InputPath => DrivePath; #else - public override string? InputPath => DriveLetter; + public override string? InputPath => DrivePath; #endif /// @@ -54,9 +54,9 @@ namespace MPF.Core.Modules.DiscImageCreator /// Drive letter or path to pass to DiscImageCreator /// #if NET48 - public string DriveLetter { get; set; } + public string DrivePath { get; set; } #else - public string? DriveLetter { get; set; } + public string? DrivePath { get; set; } #endif /// @@ -193,8 +193,12 @@ namespace MPF.Core.Modules.DiscImageCreator #endif /// - public Parameters(RedumpSystem? system, MediaType? type, char driveLetter, string filename, int? driveSpeed, Options options) - : base(system, type, driveLetter, filename, driveSpeed, options) +#if NET48 + public Parameters(RedumpSystem? system, MediaType? type, string drivePath, string filename, int? driveSpeed, Options options) +#else + public Parameters(RedumpSystem? system, MediaType? type, string? drivePath, string filename, int? driveSpeed, Options options) +#endif + : base(system, type, drivePath, filename, driveSpeed, options) { } @@ -613,7 +617,7 @@ namespace MPF.Core.Modules.DiscImageCreator break; case RedumpSystem.KonamiPython2: - if (InfoTool.GetPlayStationExecutableInfo(drive?.Letter, out var pythonTwoSerial, out Region? pythonTwoRegion, out var pythonTwoDate)) + if (InfoTool.GetPlayStationExecutableInfo(drive?.Name, out var pythonTwoSerial, out Region? pythonTwoRegion, out var pythonTwoDate)) { // Ensure internal serial is pulled from local data #if NET48 @@ -626,9 +630,9 @@ namespace MPF.Core.Modules.DiscImageCreator } #if NET48 - info.VersionAndEditions.Version = InfoTool.GetPlayStation2Version(drive?.Letter) ?? string.Empty; + info.VersionAndEditions.Version = InfoTool.GetPlayStation2Version(drive?.Name) ?? string.Empty; #else - info.VersionAndEditions!.Version = InfoTool.GetPlayStation2Version(drive?.Letter) ?? string.Empty; + info.VersionAndEditions!.Version = InfoTool.GetPlayStation2Version(drive?.Name) ?? string.Empty; #endif break; @@ -977,7 +981,7 @@ namespace MPF.Core.Modules.DiscImageCreator break; case RedumpSystem.SonyPlayStation: - if (InfoTool.GetPlayStationExecutableInfo(drive?.Letter, out var playstationSerial, out Region? playstationRegion, out var playstationDate)) + if (InfoTool.GetPlayStationExecutableInfo(drive?.Name, out var playstationSerial, out Region? playstationRegion, out var playstationDate)) { // Ensure internal serial is pulled from local data #if NET48 @@ -1005,7 +1009,7 @@ namespace MPF.Core.Modules.DiscImageCreator break; case RedumpSystem.SonyPlayStation2: - if (InfoTool.GetPlayStationExecutableInfo(drive?.Letter, out var playstationTwoSerial, out Region? playstationTwoRegion, out var playstationTwoDate)) + if (InfoTool.GetPlayStationExecutableInfo(drive?.Name, out var playstationTwoSerial, out Region? playstationTwoRegion, out var playstationTwoDate)) { // Ensure internal serial is pulled from local data #if NET48 @@ -1018,39 +1022,39 @@ namespace MPF.Core.Modules.DiscImageCreator } #if NET48 - info.VersionAndEditions.Version = InfoTool.GetPlayStation2Version(drive?.Letter) ?? string.Empty; + info.VersionAndEditions.Version = InfoTool.GetPlayStation2Version(drive?.Name) ?? string.Empty; #else - info.VersionAndEditions!.Version = InfoTool.GetPlayStation2Version(drive?.Letter) ?? string.Empty; + info.VersionAndEditions!.Version = InfoTool.GetPlayStation2Version(drive?.Name) ?? string.Empty; #endif break; case RedumpSystem.SonyPlayStation3: #if NET48 - info.VersionAndEditions.Version = InfoTool.GetPlayStation3Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation3Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions.Version = InfoTool.GetPlayStation3Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation3Serial(drive?.Name) ?? string.Empty; #else - info.VersionAndEditions!.Version = InfoTool.GetPlayStation3Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation3Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions!.Version = InfoTool.GetPlayStation3Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation3Serial(drive?.Name) ?? string.Empty; #endif break; case RedumpSystem.SonyPlayStation4: #if NET48 - info.VersionAndEditions.Version = InfoTool.GetPlayStation4Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation4Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions.Version = InfoTool.GetPlayStation4Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation4Serial(drive?.Name) ?? string.Empty; #else - info.VersionAndEditions!.Version = InfoTool.GetPlayStation4Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation4Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions!.Version = InfoTool.GetPlayStation4Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation4Serial(drive?.Name) ?? string.Empty; #endif break; case RedumpSystem.SonyPlayStation5: #if NET48 - info.VersionAndEditions.Version = InfoTool.GetPlayStation5Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation5Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions.Version = InfoTool.GetPlayStation5Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation5Serial(drive?.Name) ?? string.Empty; #else - info.VersionAndEditions!.Version = InfoTool.GetPlayStation5Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation5Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions!.Version = InfoTool.GetPlayStation5Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation5Serial(drive?.Name) ?? string.Empty; #endif break; } @@ -1160,8 +1164,8 @@ namespace MPF.Core.Modules.DiscImageCreator || BaseCommand == CommandStrings.XGD2Swap || BaseCommand == CommandStrings.XGD3Swap) { - if (DriveLetter != null) - parameters.Add(DriveLetter); + if (DrivePath != null) + parameters.Add(DrivePath); else return null; } @@ -2030,7 +2034,7 @@ namespace MPF.Core.Modules.DiscImageCreator { BaseCommand = CommandStrings.NONE; - DriveLetter = null; + DrivePath = null; DriveSpeed = null; Filename = null; @@ -2053,11 +2057,15 @@ namespace MPF.Core.Modules.DiscImageCreator } /// - protected override void SetDefaultParameters(char driveLetter, string filename, int? driveSpeed, Options options) +#if NET48 + protected override void SetDefaultParameters(string drivePath, string filename, int? driveSpeed, Options options) +#else + protected override void SetDefaultParameters(string? drivePath, string filename, int? driveSpeed, Options options) +#endif { SetBaseCommand(this.System, this.Type); - DriveLetter = driveLetter.ToString(); + DrivePath = drivePath; DriveSpeed = driveSpeed; Filename = filename; @@ -2219,7 +2227,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; if (IsFlagSupported(parts[2])) return false; @@ -2251,7 +2259,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; if (IsFlagSupported(parts[2])) return false; @@ -2273,7 +2281,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; break; @@ -2284,7 +2292,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; if (IsFlagSupported(parts[2])) return false; @@ -2306,7 +2314,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; if (IsFlagSupported(parts[2])) return false; @@ -2338,7 +2346,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; if (IsFlagSupported(parts[2])) return false; @@ -2360,7 +2368,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; if (IsFlagSupported(parts[2])) return false; @@ -2376,7 +2384,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; break; @@ -2387,7 +2395,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; break; @@ -2398,7 +2406,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; if (IsFlagSupported(parts[2])) return false; @@ -2414,7 +2422,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; if (IsFlagSupported(parts[2])) return false; @@ -2463,7 +2471,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; break; @@ -2474,7 +2482,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; if (IsFlagSupported(parts[2])) return false; @@ -2496,7 +2504,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; break; @@ -2507,7 +2515,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; break; @@ -2529,7 +2537,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; if (IsFlagSupported(parts[2])) return false; @@ -2568,7 +2576,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; if (IsFlagSupported(parts[2])) return false; @@ -2592,7 +2600,7 @@ namespace MPF.Core.Modules.DiscImageCreator if (!IsValidDriveLetter(parts[1])) return false; else - DriveLetter = parts[1]; + DrivePath = parts[1]; if (IsFlagSupported(parts[2])) return false; diff --git a/MPF.Core/Modules/Redumper/Parameters.cs b/MPF.Core/Modules/Redumper/Parameters.cs index 66bb2dc2..cb6ddd5a 100644 --- a/MPF.Core/Modules/Redumper/Parameters.cs +++ b/MPF.Core/Modules/Redumper/Parameters.cs @@ -217,8 +217,12 @@ namespace MPF.Core.Modules.Redumper #endif /// - public Parameters(RedumpSystem? system, MediaType? type, char driveLetter, string filename, int? driveSpeed, Options options) - : base(system, type, driveLetter, filename, driveSpeed, options) +#if NET48 + public Parameters(RedumpSystem? system, MediaType? type, string drivePath, string filename, int? driveSpeed, Options options) +#else + public Parameters(RedumpSystem? system, MediaType? type, string? drivePath, string filename, int? driveSpeed, Options options) +#endif + : base(system, type, drivePath, filename, driveSpeed, options) { } @@ -426,7 +430,7 @@ namespace MPF.Core.Modules.Redumper break; case RedumpSystem.KonamiPython2: - if (InfoTool.GetPlayStationExecutableInfo(drive?.Letter, out var pythonTwoSerial, out Region? pythonTwoRegion, out var pythonTwoDate)) + if (InfoTool.GetPlayStationExecutableInfo(drive?.Name, out var pythonTwoSerial, out Region? pythonTwoRegion, out var pythonTwoDate)) { // Ensure internal serial is pulled from local data #if NET48 @@ -439,9 +443,9 @@ namespace MPF.Core.Modules.Redumper } #if NET48 - info.VersionAndEditions.Version = InfoTool.GetPlayStation2Version(drive?.Letter) ?? string.Empty; + info.VersionAndEditions.Version = InfoTool.GetPlayStation2Version(drive?.Name) ?? string.Empty; #else - info.VersionAndEditions!.Version = InfoTool.GetPlayStation2Version(drive?.Letter) ?? string.Empty; + info.VersionAndEditions!.Version = InfoTool.GetPlayStation2Version(drive?.Name) ?? string.Empty; #endif break; @@ -512,7 +516,7 @@ namespace MPF.Core.Modules.Redumper break; case RedumpSystem.SonyPlayStation: - if (InfoTool.GetPlayStationExecutableInfo(drive?.Letter, out var playstationSerial, out Region? playstationRegion, out var playstationDate)) + if (InfoTool.GetPlayStationExecutableInfo(drive?.Name, out var playstationSerial, out Region? playstationRegion, out var playstationDate)) { // Ensure internal serial is pulled from local data #if NET48 @@ -536,7 +540,7 @@ namespace MPF.Core.Modules.Redumper break; case RedumpSystem.SonyPlayStation2: - if (InfoTool.GetPlayStationExecutableInfo(drive?.Letter, out var playstationTwoSerial, out Region? playstationTwoRegion, out var playstationTwoDate)) + if (InfoTool.GetPlayStationExecutableInfo(drive?.Name, out var playstationTwoSerial, out Region? playstationTwoRegion, out var playstationTwoDate)) { // Ensure internal serial is pulled from local data #if NET48 @@ -549,39 +553,39 @@ namespace MPF.Core.Modules.Redumper } #if NET48 - info.VersionAndEditions.Version = InfoTool.GetPlayStation2Version(drive?.Letter) ?? string.Empty; + info.VersionAndEditions.Version = InfoTool.GetPlayStation2Version(drive?.Name) ?? string.Empty; #else - info.VersionAndEditions!.Version = InfoTool.GetPlayStation2Version(drive?.Letter) ?? string.Empty; + info.VersionAndEditions!.Version = InfoTool.GetPlayStation2Version(drive?.Name) ?? string.Empty; #endif break; case RedumpSystem.SonyPlayStation3: #if NET48 - info.VersionAndEditions.Version = InfoTool.GetPlayStation3Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation3Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions.Version = InfoTool.GetPlayStation3Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation3Serial(drive?.Name) ?? string.Empty; #else - info.VersionAndEditions!.Version = InfoTool.GetPlayStation3Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation3Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions!.Version = InfoTool.GetPlayStation3Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation3Serial(drive?.Name) ?? string.Empty; #endif break; case RedumpSystem.SonyPlayStation4: #if NET48 - info.VersionAndEditions.Version = InfoTool.GetPlayStation4Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation4Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions.Version = InfoTool.GetPlayStation4Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation4Serial(drive?.Name) ?? string.Empty; #else - info.VersionAndEditions!.Version = InfoTool.GetPlayStation4Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation4Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions!.Version = InfoTool.GetPlayStation4Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation4Serial(drive?.Name) ?? string.Empty; #endif break; case RedumpSystem.SonyPlayStation5: #if NET48 - info.VersionAndEditions.Version = InfoTool.GetPlayStation5Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation5Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions.Version = InfoTool.GetPlayStation5Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo.CommentsSpecialFields[SiteCode.InternalSerialName] = InfoTool.GetPlayStation5Serial(drive?.Name) ?? string.Empty; #else - info.VersionAndEditions!.Version = InfoTool.GetPlayStation5Version(drive?.Letter) ?? string.Empty; - info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation5Serial(drive?.Letter) ?? string.Empty; + info.VersionAndEditions!.Version = InfoTool.GetPlayStation5Version(drive?.Name) ?? string.Empty; + info.CommonDiscInfo!.CommentsSpecialFields![SiteCode.InternalSerialName] = InfoTool.GetPlayStation5Serial(drive?.Name) ?? string.Empty; #endif break; } @@ -1025,7 +1029,11 @@ namespace MPF.Core.Modules.Redumper } /// - protected override void SetDefaultParameters(char driveLetter, string filename, int? driveSpeed, Options options) +#if NET48 + protected override void SetDefaultParameters(string drivePath, string filename, int? driveSpeed, Options options) +#else + protected override void SetDefaultParameters(string? drivePath, string filename, int? driveSpeed, Options options) +#endif { // If we don't have a CD or DVD, we can't dump using redumper if (this.Type != MediaType.CDROM && this.Type != MediaType.DVD) @@ -1065,7 +1073,7 @@ namespace MPF.Core.Modules.Redumper } this[FlagStrings.Drive] = true; - DriveValue = driveLetter.ToString(); + DriveValue = drivePath; this[FlagStrings.Speed] = true; SpeedValue = driveSpeed; diff --git a/MPF.Core/Modules/UmdImageCreator/Parameters.cs b/MPF.Core/Modules/UmdImageCreator/Parameters.cs index 3205e449..b718d3a3 100644 --- a/MPF.Core/Modules/UmdImageCreator/Parameters.cs +++ b/MPF.Core/Modules/UmdImageCreator/Parameters.cs @@ -28,8 +28,12 @@ namespace MPF.Core.Modules.UmdImageCreator #endif /// - public Parameters(RedumpSystem? system, MediaType? type, char driveLetter, string filename, int? driveSpeed, Options options) - : base(system, type, driveLetter, filename, driveSpeed, options) +#if NET48 + public Parameters(RedumpSystem? system, MediaType? type, string drivePath, string filename, int? driveSpeed, Options options) +#else + public Parameters(RedumpSystem? system, MediaType? type, string? drivePath, string filename, int? driveSpeed, Options options) +#endif + : base(system, type, drivePath, filename, driveSpeed, options) { } diff --git a/MPF.Core/Protection.cs b/MPF.Core/Protection.cs index 86ef1a01..fe88cd5e 100644 --- a/MPF.Core/Protection.cs +++ b/MPF.Core/Protection.cs @@ -95,8 +95,16 @@ namespace MPF.Core /// /// Path to scan for anti-modchip strings /// Anti-modchip existence if possible, false on error +#if NET48 public static async Task GetPlayStationAntiModchipDetected(string path) +#else + public static async Task GetPlayStationAntiModchipDetected(string? path) +#endif { + // If there is no valid path + if (string.IsNullOrEmpty(path)) + return false; + return await Task.Run(() => { try diff --git a/MPF.Core/SubmissionInfoTool.cs b/MPF.Core/SubmissionInfoTool.cs index 8eff85ca..f9f70d5d 100644 --- a/MPF.Core/SubmissionInfoTool.cs +++ b/MPF.Core/SubmissionInfoTool.cs @@ -740,9 +740,9 @@ namespace MPF.Core break; case RedumpSystem.MicrosoftXboxOne: - if (drive != null) + if (drive?.Name != null) { - string xboxOneMsxcPath = Path.Combine($"{drive.Letter}:\\", "MSXC"); + string xboxOneMsxcPath = Path.Combine(drive.Name, "MSXC"); if (drive != null && Directory.Exists(xboxOneMsxcPath)) { #if NET48 @@ -757,9 +757,9 @@ namespace MPF.Core break; case RedumpSystem.MicrosoftXboxSeriesXS: - if (drive != null) + if (drive?.Name != null) { - string xboxSeriesXMsxcPath = Path.Combine($"{drive.Letter}:\\", "MSXC"); + string xboxSeriesXMsxcPath = Path.Combine(drive.Name, "MSXC"); if (drive != null && Directory.Exists(xboxSeriesXMsxcPath)) { #if NET48 diff --git a/MPF.Core/UI/ViewModels/MainViewModel.cs b/MPF.Core/UI/ViewModels/MainViewModel.cs index 19a1867a..ac3f0e6e 100644 --- a/MPF.Core/UI/ViewModels/MainViewModel.cs +++ b/MPF.Core/UI/ViewModels/MainViewModel.cs @@ -618,19 +618,19 @@ namespace MPF.Core.UI.ViewModels this.UpdateVolumeLabelEnabled = true; // If we have a selected drive, keep track of it - char? lastSelectedDrive = this.CurrentDrive?.Letter; + char? lastSelectedDrive = this.CurrentDrive?.Name?[0] ?? null; // Populate the list of drives and add it to the combo box Drives = Drive.CreateListOfDrives(this.Options.IgnoreFixedDrives); if (Drives.Count > 0) { - VerboseLogLn($"Found {Drives.Count} drives: {string.Join(", ", Drives.Select(d => d.Letter))}"); + VerboseLogLn($"Found {Drives.Count} drives: {string.Join(", ", Drives.Select(d => d.Name))}"); // Check for the last selected drive, if possible int index = -1; if (lastSelectedDrive != null) - index = Drives.FindIndex(d => d.MarkedActive && d.Letter == lastSelectedDrive); + index = Drives.FindIndex(d => d.MarkedActive && (d.Name?[0] ?? '\0') == lastSelectedDrive); // Check for active optical drives if (index == -1) @@ -965,13 +965,13 @@ namespace MPF.Core.UI.ViewModels if (_environment != null && _environment.Options.EjectAfterDump) { - VerboseLogLn($"Ejecting disc in drive {_environment.Drive?.Letter}"); + VerboseLogLn($"Ejecting disc in drive {_environment.Drive?.Name}"); await _environment.EjectDisc(); } if (_environment != null && this.Options.DICResetDriveAfterDump) { - VerboseLogLn($"Resetting drive {_environment.Drive?.Letter}"); + VerboseLogLn($"Resetting drive {_environment.Drive?.Name}"); await _environment.ResetDrive(); } } @@ -1203,7 +1203,7 @@ namespace MPF.Core.UI.ViewModels // If the drive is marked active, try to read from it else if (this.CurrentDrive.MarkedActive) { - VerboseLog($"Trying to detect media type for drive {this.CurrentDrive.Letter} [{this.CurrentDrive.DriveFormat}] using size and filesystem.. "); + VerboseLog($"Trying to detect media type for drive {this.CurrentDrive.Name} [{this.CurrentDrive.DriveFormat}] using size and filesystem.. "); (MediaType? detectedMediaType, var errorMessage) = this.CurrentDrive.GetMediaType(this.CurrentSystem); // If we got an error message, post it to the log @@ -1263,7 +1263,7 @@ namespace MPF.Core.UI.ViewModels } else if (!this.Options.SkipSystemDetection) { - VerboseLog($"Trying to detect system for drive {this.CurrentDrive.Letter}.. "); + VerboseLog($"Trying to detect system for drive {this.CurrentDrive.Name}.. "); var currentSystem = this.CurrentDrive?.GetRedumpSystem(this.Options.DefaultSystem) ?? this.Options.DefaultSystem; VerboseLogLn(currentSystem == null ? "unable to detect." : ($"detected {currentSystem.LongName()}.")); @@ -1431,7 +1431,7 @@ namespace MPF.Core.UI.ViewModels // Catch this in case there's an input path issue try { - int driveIndex = Drives.Select(d => d.Letter).ToList().IndexOf(_environment.Parameters?.InputPath?[0] ?? default); + int driveIndex = Drives.Select(d => d.Name?[0] ?? '\0').ToList().IndexOf(_environment.Parameters?.InputPath?[0] ?? default); this.CurrentDrive = (driveIndex != -1 ? Drives[driveIndex] : Drives[0]); } catch { } @@ -1476,10 +1476,10 @@ namespace MPF.Core.UI.ViewModels #endif // If we don't have a valid drive - if (this.CurrentDrive == null || this.CurrentDrive.Letter == default(char)) + if (this.CurrentDrive?.Name == null) return (null, "No valid drive found!"); - VerboseLogLn($"Scanning for copy protection in {this.CurrentDrive.Letter}"); + VerboseLogLn($"Scanning for copy protection in {this.CurrentDrive.Name}"); var tempContent = this.Status; this.Status = "Scanning for copy protection... this might take a while!"; @@ -1490,7 +1490,7 @@ namespace MPF.Core.UI.ViewModels var progress = new Progress(); progress.ProgressChanged += ProgressUpdated; - var (protections, error) = await Protection.RunProtectionScanOnPath(this.CurrentDrive.Letter + ":\\", this.Options, progress); + var (protections, error) = await Protection.RunProtectionScanOnPath(this.CurrentDrive.Name, this.Options, progress); var output = Protection.FormatProtections(protections); // If SmartE is detected on the current disc, remove `/sf` from the flags for DIC only -- Disabled until further notice @@ -1502,7 +1502,7 @@ namespace MPF.Core.UI.ViewModels //} if (string.IsNullOrEmpty(error)) - LogLn($"Detected the following protections in {this.CurrentDrive.Letter}:\r\n\r\n{output}"); + LogLn($"Detected the following protections in {this.CurrentDrive.Name}:\r\n\r\n{output}"); else ErrorLogLn($"Path could not be scanned! Exception information:\r\n\r\n{error}"); diff --git a/MPF.Test/Modules/DiscImageCreatorTests.cs b/MPF.Test/Modules/DiscImageCreatorTests.cs index 3f70b01d..1df281f0 100644 --- a/MPF.Test/Modules/DiscImageCreatorTests.cs +++ b/MPF.Test/Modules/DiscImageCreatorTests.cs @@ -21,7 +21,7 @@ namespace MPF.Test.Modules public void ParametersFromSystemAndTypeTest(RedumpSystem? knownSystem, MediaType? mediaType, string expected) { var options = new Options(); - var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options); + var actual = new Parameters(knownSystem, mediaType, "D:\\", "disc.bin", 16, options); Assert.Equal(expected, actual.BaseCommand); } @@ -32,7 +32,7 @@ namespace MPF.Test.Modules public void ParametersFromOptionsSpecialDefaultTest(RedumpSystem? knownSystem, MediaType? mediaType,string[] expected) { var options = new Options(); - var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options); + var actual = new Parameters(knownSystem, mediaType, "D:\\", "disc.bin", 16, options); var expectedSet = new HashSet(expected ?? Array.Empty()); HashSet actualSet = GenerateUsedKeys(actual); @@ -45,7 +45,7 @@ namespace MPF.Test.Modules public void ParametersFromOptionsC2RereadTest(RedumpSystem? knownSystem, MediaType? mediaType, int rereadC2, string[] expected) { var options = new Options { DICRereadCount = rereadC2 }; - var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options); + var actual = new Parameters(knownSystem, mediaType, "D:\\", "disc.bin", 16, options); var expectedSet = new HashSet(expected ?? Array.Empty()); HashSet actualSet = GenerateUsedKeys(actual); @@ -65,7 +65,7 @@ namespace MPF.Test.Modules public void ParametersFromOptionsDVDRereadTest(RedumpSystem? knownSystem, MediaType? mediaType, int rereadDVDBD, string[] expected) { var options = new Options { DICDVDRereadCount = rereadDVDBD }; - var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options); + var actual = new Parameters(knownSystem, mediaType, "D:\\", "disc.bin", 16, options); var expectedSet = new HashSet(expected ?? Array.Empty()); HashSet actualSet = GenerateUsedKeys(actual); @@ -89,7 +89,7 @@ namespace MPF.Test.Modules public void ParametersFromOptionsMultiSectorReadTest(RedumpSystem? knownSystem, MediaType? mediaType, bool multiSectorRead, string[] expected) { var options = new Options { DICMultiSectorRead = multiSectorRead }; - var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options); + var actual = new Parameters(knownSystem, mediaType, "D:\\", "disc.bin", 16, options); var expectedSet = new HashSet(expected ?? Array.Empty()); HashSet actualSet = GenerateUsedKeys(actual); @@ -110,7 +110,7 @@ namespace MPF.Test.Modules public void ParametersFromOptionsParanoidModeTest(RedumpSystem? knownSystem, MediaType? mediaType, bool paranoidMode, string[] expected) { var options = new Options { DICParanoidMode = paranoidMode }; - var actual = new Parameters(knownSystem, mediaType, 'D', "disc.bin", 16, options); + var actual = new Parameters(knownSystem, mediaType, "D:\\", "disc.bin", 16, options); var expectedSet = new HashSet(expected ?? Array.Empty()); HashSet actualSet = GenerateUsedKeys(actual);