Use PSX/PS2 serial as filename when Volume Label not present (#623)

* Use PSX/PS2 serial as volume label if none found

* Refactor
This commit is contained in:
Deterous
2024-01-10 11:02:17 +13:00
committed by GitHub
parent 01cbd2cff5
commit 53b31f91cf
2 changed files with 22 additions and 5 deletions

View File

@@ -9,6 +9,7 @@
- Support ringcode and PIC for triple/quad-layer (fuzz6001)
- Cleanup !protectionInfo.txt (Deterous)
- Update Redumper to build 311 (Deterous)
- Use PSX/PS2 serial as filename when Volume Label not present (Deterous)
### 3.0.3 (2023-12-04)

View File

@@ -58,18 +58,34 @@ namespace MPF.Core.Data
/// <summary>
/// Media label as read by Windows, formatted to avoid odd outputs
/// If no volume label present, use PSX or PS2 serial if valid
/// Otherwise, use "track" as volume label
/// </summary>
public string? FormattedVolumeLabel
{
get
{
string? volumeLabel = Template.DiscNotDetected;
if (this.MarkedActive)
if (!this.MarkedActive)
return volumeLabel;
if (!string.IsNullOrEmpty(this.VolumeLabel))
volumeLabel = this.VolumeLabel;
else
{
if (string.IsNullOrEmpty(this.VolumeLabel))
volumeLabel = "track";
else
volumeLabel = this.VolumeLabel;
// No Volume Label found, fallback to something sensible
switch (this.GetRedumpSystem(null))
{
case RedumpSystem.SonyPlayStation:
case RedumpSystem.SonyPlayStation2:
InfoTool.GetPlayStationExecutableInfo(this.Name, out string? serial, out _, out _);
volumeLabel = serial ?? "track";
break;
default:
volumeLabel = "track";
break;
}
}
foreach (char c in Path.GetInvalidFileNameChars())