From 9d8181b0e20fb93f71fdee48c67443b71fbfbdf6 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 18 Oct 2023 01:29:26 -0400 Subject: [PATCH] Add path variants for PlayStation info --- CHANGELIST.md | 1 + MPF.Core/InfoTool.cs | 169 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+) diff --git a/CHANGELIST.md b/CHANGELIST.md index 140ecba0..a5d0d071 100644 --- a/CHANGELIST.md +++ b/CHANGELIST.md @@ -1,6 +1,7 @@ ### WIP (xxxx-xx-xx) - Split InfoTool into 2 classes +- Add path variants for PlayStation info ### 2.7.2 (2023-10-17) diff --git a/MPF.Core/InfoTool.cs b/MPF.Core/InfoTool.cs index af43ba40..f7fe0008 100644 --- a/MPF.Core/InfoTool.cs +++ b/MPF.Core/InfoTool.cs @@ -561,6 +561,30 @@ namespace MPF.Core // If the folder no longer exists, we can't do this part string drivePath = driveLetter + ":\\"; + return GetPlayStationExecutableInfo(drivePath, out serial, out region, out date); + } + + /// + /// Get the EXE date from a PlayStation disc, if possible + /// + /// Drive path to use to check + /// Internal disc serial, if possible + /// Output region, if possible + /// Output EXE date in "yyyy-mm-dd" format if possible, null on error + /// +#if NET48 + internal static bool GetPlayStationExecutableInfo(string drivePath, out string serial, out Region? region, out string date) +#else + internal static bool GetPlayStationExecutableInfo(string? drivePath, out string? serial, out Region? region, out string? date) +#endif + { + serial = null; region = null; date = null; + + // If there's no drive path, we can't do this part + if (string.IsNullOrWhiteSpace(drivePath)) + return false; + + // If the folder no longer exists, we can't do this part if (!Directory.Exists(drivePath)) return false; @@ -651,6 +675,25 @@ namespace MPF.Core // If the folder no longer exists, we can't do this part string drivePath = driveLetter + ":\\"; + return (GetPlayStation2Version(drivePath)); + } + + /// + /// Get the version from a PlayStation 2 disc, if possible + /// + /// Drive path to use to check + /// Game version if possible, null on error +#if NET48 + internal static string GetPlayStation2Version(string drivePath) +#else + internal static string? GetPlayStation2Version(string? drivePath) +#endif + { + // If there's no drive path, we can't do this part + if (string.IsNullOrWhiteSpace(drivePath)) + return null; + + // If the folder no longer exists, we can't do this part if (!Directory.Exists(drivePath)) return null; @@ -683,6 +726,25 @@ namespace MPF.Core // If the folder no longer exists, we can't do this part string drivePath = driveLetter + ":\\"; + return GetPlayStation3Serial(drivePath); + } + + /// + /// Get the internal serial from a PlayStation 3 disc, if possible + /// + /// Drive path to use to check + /// Internal disc serial if possible, null on error +#if NET48 + internal static string GetPlayStation3Serial(string drivePath) +#else + internal static string? GetPlayStation3Serial(string? drivePath) +#endif + { + // If there's no drive path, we can't do this part + if (string.IsNullOrWhiteSpace(drivePath)) + return null; + + // If the folder no longer exists, we can't do this part if (!Directory.Exists(drivePath)) return null; @@ -724,6 +786,25 @@ namespace MPF.Core // If the folder no longer exists, we can't do this part string drivePath = driveLetter + ":\\"; + return GetPlayStation3Version(drivePath); + } + + /// + /// Get the version from a PlayStation 3 disc, if possible + /// + /// Drive path to use to check + /// Game version if possible, null on error +#if NET48 + internal static string GetPlayStation3Version(string drivePath) +#else + internal static string? GetPlayStation3Version(string? drivePath) +#endif + { + // If there's no drive path, we can't do this part + if (string.IsNullOrWhiteSpace(drivePath)) + return null; + + // If the folder no longer exists, we can't do this part if (!Directory.Exists(drivePath)) return null; @@ -765,6 +846,25 @@ namespace MPF.Core // If the folder no longer exists, we can't do this part string drivePath = driveLetter + ":\\"; + return GetPlayStation4Serial(drivePath); + } + + /// + /// Get the internal serial from a PlayStation 4 disc, if possible + /// + /// Drive path to use to check + /// Internal disc serial if possible, null on error +#if NET48 + internal static string GetPlayStation4Serial(string drivePath) +#else + internal static string? GetPlayStation4Serial(string? drivePath) +#endif + { + // If there's no drive path, we can't do this part + if (string.IsNullOrWhiteSpace(drivePath)) + return null; + + // If the folder no longer exists, we can't do this part if (!Directory.Exists(drivePath)) return null; @@ -806,6 +906,25 @@ namespace MPF.Core // If the folder no longer exists, we can't do this part string drivePath = driveLetter + ":\\"; + return GetPlayStation4Version(drivePath); + } + + /// + /// Get the version from a PlayStation 4 disc, if possible + /// + /// Drive path to use to check + /// Game version if possible, null on error +#if NET48 + internal static string GetPlayStation4Version(string drivePath) +#else + internal static string? GetPlayStation4Version(string? drivePath) +#endif + { + // If there's no drive path, we can't do this part + if (string.IsNullOrWhiteSpace(drivePath)) + return null; + + // If the folder no longer exists, we can't do this part if (!Directory.Exists(drivePath)) return null; @@ -847,6 +966,25 @@ namespace MPF.Core // If the folder no longer exists, we can't do this part string drivePath = driveLetter + ":\\"; + return GetPlayStation5Serial(drivePath); + } + + /// + /// Get the internal serial from a PlayStation 5 disc, if possible + /// + /// Drive path to use to check + /// Internal disc serial if possible, null on error +#if NET48 + internal static string GetPlayStation5Serial(string drivePath) +#else + internal static string? GetPlayStation5Serial(string? drivePath) +#endif + { + // If there's no drive path, we can't do this part + if (string.IsNullOrWhiteSpace(drivePath)) + return null; + + // If the folder no longer exists, we can't do this part if (!Directory.Exists(drivePath)) return null; @@ -888,6 +1026,25 @@ namespace MPF.Core // If the folder no longer exists, we can't do this part string drivePath = driveLetter + ":\\"; + return GetPlayStation5Version(drivePath); + } + + /// + /// Get the version from a PlayStation 5 disc, if possible + /// + /// Drive path to use to check + /// Game version if possible, null on error +#if NET48 + internal static string GetPlayStation5Version(string drivePath) +#else + internal static string? GetPlayStation5Version(string? drivePath) +#endif + { + // If there's no drive path, we can't do this part + if (string.IsNullOrWhiteSpace(drivePath)) + return null; + + // If the folder no longer exists, we can't do this part if (!Directory.Exists(drivePath)) return null; @@ -921,7 +1078,11 @@ namespace MPF.Core /// /// String representing the category /// Category, if possible +#if NET48 internal static DiscCategory? GetUMDCategory(string category) +#else + internal static DiscCategory? GetUMDCategory(string? category) +#endif { #if NET48 switch (category) @@ -951,8 +1112,16 @@ namespace MPF.Core /// /// PlayStation serial code /// Region mapped from name, if possible +#if NET48 internal static Region? GetPlayStationRegion(string serial) +#else + internal static Region? GetPlayStationRegion(string? serial) +#endif { + // If we have a fully invalid serial + if (string.IsNullOrWhiteSpace(serial)) + return null; + // Standardized "S" serials if (serial.StartsWith("S")) {