From 1886e14a9b68112ea538710136f854d1e2e067d5 Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Tue, 5 Mar 2024 23:34:38 +0900 Subject: [PATCH] Use a trimmed DiscUtils --- IRDKit/Program.cs | 6 +++--- LibIRD/DiscUtils | 2 +- LibIRD/IRD.cs | 24 ++++++++++++------------ LibIRD/ReIRD.cs | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/IRDKit/Program.cs b/IRDKit/Program.cs index 4feb25d..8cf8841 100644 --- a/IRDKit/Program.cs +++ b/IRDKit/Program.cs @@ -292,7 +292,7 @@ namespace IRDKit { PrintISO(file, opt.Json, file.Equals(lastISO), opt.OutPath); } - catch (LibIRD.DiscUtils.InvalidFileSystemException) + catch (IOException) { // Not a valid ISO file despite extension, assume file is an IRD if (!opt.Json) @@ -473,7 +473,7 @@ namespace IRDKit PrintISO(inPath, json, single, outPath); return; } - catch (LibIRD.DiscUtils.InvalidFileSystemException) + catch (IOException) { // Not a valid ISO file despite extension, try open as IRD } @@ -529,7 +529,7 @@ namespace IRDKit return; } // Create new ISO reader - using LibIRD.DiscUtils.Iso9660.CDReader reader = new(fs, true, true); + using LibIRD.DiscUtils.Iso9660.CDReader reader = new(fs); // Write PS3_DISC.SFB info try diff --git a/LibIRD/DiscUtils b/LibIRD/DiscUtils index bd00436..b39f8dc 160000 --- a/LibIRD/DiscUtils +++ b/LibIRD/DiscUtils @@ -1 +1 @@ -Subproject commit bd00436598e2687004b4fb19c2968db046f0321c +Subproject commit b39f8dc4ab71539af4d1626dcef16bdbd3df30d1 diff --git a/LibIRD/IRD.cs b/LibIRD/IRD.cs index aec3f3c..9f968a6 100644 --- a/LibIRD/IRD.cs +++ b/LibIRD/IRD.cs @@ -618,17 +618,17 @@ namespace LibIRD /// True if redump-style IRD /// /// - /// + /// private protected void GenerateIRD(string isoPath, bool redump = false) { // Parse ISO file as a file stream using FileStream fs = new FileStream(isoPath, FileMode.Open, FileAccess.Read, FileShare.Read, 4096, FileOptions.SequentialScan) ?? throw new FileNotFoundException(isoPath); // Validate ISO file stream if (!CDReader.Detect(fs)) - throw new InvalidFileSystemException("Not a valid ISO file"); + throw new IOException("Not a valid ISO file"); // New ISO Reader from DiscUtils - CDReader reader = new(fs, true, true); + CDReader reader = new(fs); // If generating redump-style IRD if (redump) @@ -747,13 +747,13 @@ namespace LibIRD /// PS3UPDAT.PUP update file version number /// ISO filestream /// CDReader - /// + /// private void GetSystemVersion(FileStream fs, CDReader reader) { // Determine PUP file offset via cluster Range[] updateClusters = reader.PathToClusters("\\PS3_UPDATE\\PS3UPDAT.PUP"); if (updateClusters == null && updateClusters.Length == 0 && updateClusters[0] == null) - throw new InvalidFileSystemException("Invalid file extents for PS3UPDAT.PUP"); + throw new IOException("Invalid file extents for PS3UPDAT.PUP"); // PS3UPDAT.PUP file begins at first byte of dedicated cluster UpdateOffset = SectorSize * updateClusters[0].Offset; @@ -791,13 +791,13 @@ namespace LibIRD /// /// ISO filestream /// CDReader - /// + /// private void GetHeader(FileStream fs, CDReader reader) { // Determine the extent of the header via cluster (Sector 0 to first data sector) Range[] sfbClusters = reader.PathToClusters("\\PS3_DISC.SFB"); if (sfbClusters == null && sfbClusters.Length == 0 && sfbClusters[0] == null) - throw new InvalidFileSystemException("Invalid file extents for PS3_DISC.SFB"); + throw new IOException("Invalid file extents for PS3_DISC.SFB"); // End of header is at beginning of first byte of dedicated cluster FirstDataSector = sfbClusters[0].Offset; @@ -867,7 +867,7 @@ namespace LibIRD /// Retreives and stores the Region extents /// /// ISO filestream - /// + /// private void GetRegions(FileStream fs) { // Determine the number of unencryted regions @@ -878,7 +878,7 @@ namespace LibIRD // Total number of regions is 2x number of unencrypted regions, minus 1 RegionCount = (byte)(2 * ((uint)decRegionCount[3]) - 1); if (RegionCount <= 0) - throw new InvalidFileSystemException("No regions detected in ISO"); + throw new IOException("No regions detected in ISO"); RegionStart = new long[RegionCount]; RegionEnd = new long[RegionCount]; @@ -928,7 +928,7 @@ namespace LibIRD // If invalid clusters were returned, we can't hash this file if (fileExtent == null && fileExtent.Length == 0) - throw new InvalidFileSystemException($"Unexpected file extents for {filePath}"); + throw new IOException($"Unexpected file extents for {filePath}"); // Determine smallest file offset as first sector long smallestOffset = fileExtent[0].Offset; @@ -936,7 +936,7 @@ namespace LibIRD for (int i = 1; i < fileExtent.Length; i++) { if (fileExtent[i] == null) - throw new InvalidFileSystemException($"Unexpected file extents for {filePath}"); + throw new IOException($"Unexpected file extents for {filePath}"); if (fileExtent[i].Offset * SectorSize != fileExtent[i - 1].Offset * SectorSize + fileExtent[i - 1].Count) nonContiguous = true; @@ -1110,7 +1110,7 @@ namespace LibIRD if (bufSectors == 0) Console.Error.WriteLine("ERROR: Trailing partial sector in ISO filestream"); if (numBytes > buf.Length) - throw new InvalidFileSystemException("ERROR: Read more bytes than buffer size???"); + throw new IOException("ERROR: Read more bytes than buffer size???"); } // Hash ISO diff --git a/LibIRD/ReIRD.cs b/LibIRD/ReIRD.cs index f9ad0c7..99ef501 100644 --- a/LibIRD/ReIRD.cs +++ b/LibIRD/ReIRD.cs @@ -133,7 +133,7 @@ namespace LibIRD { // If no layerbreak provided, ensure ISO is not BD-Video hybrid using FileStream fs = new FileStream(isoPath, FileMode.Open, FileAccess.Read) ?? throw new FileNotFoundException(isoPath); - DiscUtils.Iso9660.CDReader reader = new(fs, true, true); + DiscUtils.Iso9660.CDReader reader = new(fs); if (reader.DirectoryExists("\\BDMV")) throw new ArgumentException("Layerbreak must be provided for BD-Video hybrid discs"); // Assume disc has default layerbreak