From 1a74e8fed0c3b65dcef2c0921d7901fc742b03dd Mon Sep 17 00:00:00 2001 From: Deterous <138427222+Deterous@users.noreply.github.com> Date: Wed, 31 Jan 2024 15:03:37 +0900 Subject: [PATCH] Better path handling --- DiscUtils | 2 +- IRDKit/Program.cs | 4 ++-- LibIRD/IRD.cs | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/DiscUtils b/DiscUtils index 24d7ddc..f53a1da 160000 --- a/DiscUtils +++ b/DiscUtils @@ -1 +1 @@ -Subproject commit 24d7ddc2588837ac441260d75897ff88ba7348b8 +Subproject commit f53a1dab6167c9d79f0f63fd505ff69895070c89 diff --git a/IRDKit/Program.cs b/IRDKit/Program.cs index fa3c043..0bac339 100644 --- a/IRDKit/Program.cs +++ b/IRDKit/Program.cs @@ -366,7 +366,7 @@ namespace IRDKit // Write PARAM.SFO info try { - using DiscUtils.Streams.SparseStream s = reader.OpenFile("PS3_GAME\\PARAM.SFO", FileMode.Open, FileAccess.Read); + using DiscUtils.Streams.SparseStream s = reader.OpenFile(Path.Combine("PS3_GAME", "PARAM.SFO"), FileMode.Open, FileAccess.Read); ParamSFO paramSFO = new(s); if (json) { @@ -382,7 +382,7 @@ namespace IRDKit catch (FileNotFoundException) { if (!json) - Console.WriteLine($"PS3_GAME\\PARAM.SFO not found in {isoPath}\n"); + Console.WriteLine($"\\PS3_GAME\\PARAM.SFO not found in {isoPath}\n"); } // End JSON object diff --git a/LibIRD/IRD.cs b/LibIRD/IRD.cs index a66a040..73f1b14 100644 --- a/LibIRD/IRD.cs +++ b/LibIRD/IRD.cs @@ -658,7 +658,7 @@ namespace LibIRD } // Read PS3 Metadata from PARAM.SFO - using (DiscUtils.Streams.SparseStream s = reader.OpenFile("PS3_GAME\\PARAM.SFO", FileMode.Open, FileAccess.Read)) // Path.DirectorySeparatorChar ? + using (DiscUtils.Streams.SparseStream s = reader.OpenFile(Path.Combine("PS3_GAME", "PARAM.SFO"), FileMode.Open, FileAccess.Read)) { // Parse PARAM.SFO file ParamSFO paramSFO = new(s); @@ -710,7 +710,7 @@ namespace LibIRD // TODO: Speed up program by hashing regions and files at the same time (read from filesystem only once) // Recursively count all files in ISO to allocate file arrays - DiscDirectoryInfo rootDir = reader.GetDirectoryInfo("\\"); // Path.DirectorySeparatorChar ? + DiscDirectoryInfo rootDir = reader.GetDirectoryInfo(""); FileCount = 0; CountFiles(rootDir); FileKeys = new long[FileCount]; @@ -739,7 +739,7 @@ namespace LibIRD private void GetSystemVersion(FileStream fs, CDReader reader) { // Determine PUP file offset via cluster - DiscUtils.Streams.Range[] updateClusters = reader.PathToClusters("\\PS3_UPDATE\\PS3UPDAT.PUP"); // Path.DirectorySeparatorChar ? + DiscUtils.Streams.Range[] updateClusters = reader.PathToClusters(Path.Combine("PS3_UPDATE", "PS3UPDAT.PUP")); if (updateClusters == null && updateClusters.Length == 0 && updateClusters[0] == null) throw new InvalidFileSystemException("Invalid file extents for PS3UPDAT.PUP"); @@ -782,7 +782,7 @@ namespace LibIRD private void GetHeader(FileStream fs, CDReader reader) { // Determine the extent of the header via cluster (Sector 0 to first data sector) - DiscUtils.Streams.Range[] sfbClusters = reader.PathToClusters("\\PS3_DISC.SFB"); // Path.DirectorySeparatorChar ? + DiscUtils.Streams.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"); // End of header is at beginning of first byte of dedicated cluster