diff --git a/DICUI.Library/Aaru/Parameters.cs b/DICUI.Library/Aaru/Parameters.cs index e03e4997..f8e8c3bb 100644 --- a/DICUI.Library/Aaru/Parameters.cs +++ b/DICUI.Library/Aaru/Parameters.cs @@ -2195,6 +2195,9 @@ namespace DICUI.Aaru /// /// Convert the TrackTypeTrackType value to a CueTrackDataType /// + /// TrackTypeTrackType to convert + /// Sector size to help with specific subtypes + /// CueTrackDataType representing the input data private CueTrackDataType ConvertToDataType(TrackTypeTrackType trackType, uint bytesPerSector) { switch (trackType) @@ -2224,6 +2227,8 @@ namespace DICUI.Aaru /// /// Convert the TrackFlagsType value to a CueTrackFlag /// + /// TrackFlagsType containing flag data + /// CueTrackFlag representing the flags private CueTrackFlag ConvertToTrackFlag(TrackFlagsType trackFlagsType) { if (trackFlagsType == null) @@ -2291,7 +2296,7 @@ namespace DICUI.Aaru // Create cue file entry CueFile cueFile = new CueFile(); - cueFile.FileName = GenerateTrackName(basePath, (int)totalTracks, cueTrack.Number, track.TrackType1); + cueFile.FileName = GenerateTrackName(basePath, (int)totalTracks, cueTrack.Number, opticalDisc.DiscType); cueFile.FileType = CueFileType.BINARY; cueFile.Tracks = new List(); @@ -2412,7 +2417,7 @@ namespace DICUI.Aaru } // Build the track datfile data and append - string trackName = GenerateTrackName(basePath, (int)totalTracks, (int)trackNumber, track.TrackType1); + string trackName = GenerateTrackName(basePath, (int)totalTracks, (int)trackNumber, opticalDisc.DiscType); datfile += $"\n"; } } @@ -2462,15 +2467,16 @@ namespace DICUI.Aaru /// /// Generate a track name based on current path and tracks /// - private static string GenerateTrackName(string basePath, int totalTracks, int trackNumber, TrackTypeTrackType trackType) + /// Base path for determining file names + /// Total number of tracks in the media + /// Current track index + /// Current disc type, used for determining extension + /// Formatted string representing the track name according to Redump standards + private static string GenerateTrackName(string basePath, int totalTracks, int trackNumber, string discType) { string extension = "bin"; - if (trackType == TrackTypeTrackType.bluray - || trackType == TrackTypeTrackType.dvd - || trackType == TrackTypeTrackType.hddvd) - { + if (discType.Contains("BD") || discType.Contains("DVD")) extension = "iso"; - } string trackName = Path.GetFileNameWithoutExtension(basePath); if (totalTracks == 1) @@ -2661,11 +2667,16 @@ namespace DICUI.Aaru /// /// Generate a single 16-byte sector line from a byte array /// + /// Row ID for outputting + /// Byte span representing the data to write + /// Formatted string representing the sector line private static string GenerateSectorOutputLine(string row, ReadOnlySpan bytes) { - string pvdLine = string.Empty; + // If the data isn't correct, return null + if (bytes == null || bytes.Length != 16) + return null; - pvdLine += $"{row} : "; + string pvdLine = $"{row} : "; pvdLine += BitConverter.ToString(bytes.Slice(0, 8).ToArray()).Replace("-", " "); pvdLine += " "; pvdLine += BitConverter.ToString(bytes.Slice(8, 8).ToArray().ToArray()).Replace("-", " ");