Use a trimmed DiscUtils
This commit is contained in:
+3
-3
@@ -292,7 +292,7 @@ namespace IRDKit
|
|||||||
{
|
{
|
||||||
PrintISO(file, opt.Json, file.Equals(lastISO), opt.OutPath);
|
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
|
// Not a valid ISO file despite extension, assume file is an IRD
|
||||||
if (!opt.Json)
|
if (!opt.Json)
|
||||||
@@ -473,7 +473,7 @@ namespace IRDKit
|
|||||||
PrintISO(inPath, json, single, outPath);
|
PrintISO(inPath, json, single, outPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (LibIRD.DiscUtils.InvalidFileSystemException)
|
catch (IOException)
|
||||||
{
|
{
|
||||||
// Not a valid ISO file despite extension, try open as IRD
|
// Not a valid ISO file despite extension, try open as IRD
|
||||||
}
|
}
|
||||||
@@ -529,7 +529,7 @@ namespace IRDKit
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Create new ISO reader
|
// 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
|
// Write PS3_DISC.SFB info
|
||||||
try
|
try
|
||||||
|
|||||||
+1
-1
Submodule LibIRD/DiscUtils updated: bd00436598...b39f8dc4ab
+12
-12
@@ -618,17 +618,17 @@ namespace LibIRD
|
|||||||
/// <param name="redump">True if redump-style IRD</param>
|
/// <param name="redump">True if redump-style IRD</param>
|
||||||
/// <exception cref="ArgumentNullException"></exception>
|
/// <exception cref="ArgumentNullException"></exception>
|
||||||
/// <exception cref="FileNotFoundException"></exception>
|
/// <exception cref="FileNotFoundException"></exception>
|
||||||
/// <exception cref="InvalidFileSystemException"></exception>
|
/// <exception cref="IOException"></exception>
|
||||||
private protected void GenerateIRD(string isoPath, bool redump = false)
|
private protected void GenerateIRD(string isoPath, bool redump = false)
|
||||||
{
|
{
|
||||||
// Parse ISO file as a file stream
|
// 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);
|
using FileStream fs = new FileStream(isoPath, FileMode.Open, FileAccess.Read, FileShare.Read, 4096, FileOptions.SequentialScan) ?? throw new FileNotFoundException(isoPath);
|
||||||
// Validate ISO file stream
|
// Validate ISO file stream
|
||||||
if (!CDReader.Detect(fs))
|
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
|
// New ISO Reader from DiscUtils
|
||||||
CDReader reader = new(fs, true, true);
|
CDReader reader = new(fs);
|
||||||
|
|
||||||
// If generating redump-style IRD
|
// If generating redump-style IRD
|
||||||
if (redump)
|
if (redump)
|
||||||
@@ -747,13 +747,13 @@ namespace LibIRD
|
|||||||
/// <remarks>PS3UPDAT.PUP update file version number</remarks>
|
/// <remarks>PS3UPDAT.PUP update file version number</remarks>
|
||||||
/// <param name="fs">ISO filestream</param>
|
/// <param name="fs">ISO filestream</param>
|
||||||
/// <param name="reader">CDReader</param>
|
/// <param name="reader">CDReader</param>
|
||||||
/// <exception cref="InvalidFileSystemException"></exception>
|
/// <exception cref="IOException"></exception>
|
||||||
private void GetSystemVersion(FileStream fs, CDReader reader)
|
private void GetSystemVersion(FileStream fs, CDReader reader)
|
||||||
{
|
{
|
||||||
// Determine PUP file offset via cluster
|
// Determine PUP file offset via cluster
|
||||||
Range<long, long>[] updateClusters = reader.PathToClusters("\\PS3_UPDATE\\PS3UPDAT.PUP");
|
Range<long, long>[] updateClusters = reader.PathToClusters("\\PS3_UPDATE\\PS3UPDAT.PUP");
|
||||||
if (updateClusters == null && updateClusters.Length == 0 && updateClusters[0] == null)
|
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
|
// PS3UPDAT.PUP file begins at first byte of dedicated cluster
|
||||||
UpdateOffset = SectorSize * updateClusters[0].Offset;
|
UpdateOffset = SectorSize * updateClusters[0].Offset;
|
||||||
@@ -791,13 +791,13 @@ namespace LibIRD
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fs">ISO filestream</param>
|
/// <param name="fs">ISO filestream</param>
|
||||||
/// <param name="reader">CDReader</param>
|
/// <param name="reader">CDReader</param>
|
||||||
/// <exception cref="InvalidFileSystemException"></exception>
|
/// <exception cref="IOException"></exception>
|
||||||
private void GetHeader(FileStream fs, CDReader reader)
|
private void GetHeader(FileStream fs, CDReader reader)
|
||||||
{
|
{
|
||||||
// Determine the extent of the header via cluster (Sector 0 to first data sector)
|
// Determine the extent of the header via cluster (Sector 0 to first data sector)
|
||||||
Range<long, long>[] sfbClusters = reader.PathToClusters("\\PS3_DISC.SFB");
|
Range<long, long>[] sfbClusters = reader.PathToClusters("\\PS3_DISC.SFB");
|
||||||
if (sfbClusters == null && sfbClusters.Length == 0 && sfbClusters[0] == null)
|
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
|
// End of header is at beginning of first byte of dedicated cluster
|
||||||
FirstDataSector = sfbClusters[0].Offset;
|
FirstDataSector = sfbClusters[0].Offset;
|
||||||
|
|
||||||
@@ -867,7 +867,7 @@ namespace LibIRD
|
|||||||
/// Retreives and stores the Region extents
|
/// Retreives and stores the Region extents
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fs">ISO filestream</param>
|
/// <param name="fs">ISO filestream</param>
|
||||||
/// <exception cref="InvalidFileSystemException"></exception>
|
/// <exception cref="IOException"></exception>
|
||||||
private void GetRegions(FileStream fs)
|
private void GetRegions(FileStream fs)
|
||||||
{
|
{
|
||||||
// Determine the number of unencryted regions
|
// Determine the number of unencryted regions
|
||||||
@@ -878,7 +878,7 @@ namespace LibIRD
|
|||||||
// Total number of regions is 2x number of unencrypted regions, minus 1
|
// Total number of regions is 2x number of unencrypted regions, minus 1
|
||||||
RegionCount = (byte)(2 * ((uint)decRegionCount[3]) - 1);
|
RegionCount = (byte)(2 * ((uint)decRegionCount[3]) - 1);
|
||||||
if (RegionCount <= 0)
|
if (RegionCount <= 0)
|
||||||
throw new InvalidFileSystemException("No regions detected in ISO");
|
throw new IOException("No regions detected in ISO");
|
||||||
RegionStart = new long[RegionCount];
|
RegionStart = new long[RegionCount];
|
||||||
RegionEnd = 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 invalid clusters were returned, we can't hash this file
|
||||||
if (fileExtent == null && fileExtent.Length == 0)
|
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
|
// Determine smallest file offset as first sector
|
||||||
long smallestOffset = fileExtent[0].Offset;
|
long smallestOffset = fileExtent[0].Offset;
|
||||||
@@ -936,7 +936,7 @@ namespace LibIRD
|
|||||||
for (int i = 1; i < fileExtent.Length; i++)
|
for (int i = 1; i < fileExtent.Length; i++)
|
||||||
{
|
{
|
||||||
if (fileExtent[i] == null)
|
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)
|
if (fileExtent[i].Offset * SectorSize != fileExtent[i - 1].Offset * SectorSize + fileExtent[i - 1].Count)
|
||||||
nonContiguous = true;
|
nonContiguous = true;
|
||||||
@@ -1110,7 +1110,7 @@ namespace LibIRD
|
|||||||
if (bufSectors == 0)
|
if (bufSectors == 0)
|
||||||
Console.Error.WriteLine("ERROR: Trailing partial sector in ISO filestream");
|
Console.Error.WriteLine("ERROR: Trailing partial sector in ISO filestream");
|
||||||
if (numBytes > buf.Length)
|
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
|
// Hash ISO
|
||||||
|
|||||||
+1
-1
@@ -133,7 +133,7 @@ namespace LibIRD
|
|||||||
{
|
{
|
||||||
// If no layerbreak provided, ensure ISO is not BD-Video hybrid
|
// 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);
|
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"))
|
if (reader.DirectoryExists("\\BDMV"))
|
||||||
throw new ArgumentException("Layerbreak must be provided for BD-Video hybrid discs");
|
throw new ArgumentException("Layerbreak must be provided for BD-Video hybrid discs");
|
||||||
// Assume disc has default layerbreak
|
// Assume disc has default layerbreak
|
||||||
|
|||||||
Reference in New Issue
Block a user