Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1935404928 | ||
|
|
80e515faeb | ||
|
|
03dc5d7a0e | ||
|
|
fac8168d32 | ||
|
|
45d3b3fc7a | ||
|
|
85fbd11621 | ||
|
|
2c7e6423cf | ||
|
|
4492862051 | ||
|
|
b1cb4bccd4 | ||
|
|
2379e7ef5a |
@@ -11,20 +11,17 @@ jobs:
|
||||
matrix:
|
||||
project: [IRDKit]
|
||||
runtime: [win-x86, win-x64, win-arm64, linux-x64, linux-arm64, osx-x64, osx-arm64]
|
||||
framework: [net8.0]
|
||||
framework: [net10.0]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: 'true'
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
uses: actions/setup-dotnet@v5
|
||||
with:
|
||||
dotnet-version: 9.0.x
|
||||
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore
|
||||
dotnet-version: 10.0.x
|
||||
|
||||
- name: Build
|
||||
run: dotnet publish ${{ matrix.project }}/${{ matrix.project }}.csproj -f ${{ matrix.framework }} -r ${{ matrix.runtime }} -c Release -p:DebugType=None -p:DebugSymbols=false
|
||||
@@ -34,3 +31,43 @@ jobs:
|
||||
with:
|
||||
name: ${{ matrix.project }}_${{ matrix.framework }}_${{ matrix.runtime }}
|
||||
path: ${{ matrix.project }}/bin/Release/${{ matrix.framework }}/${{ matrix.runtime }}/publish/*
|
||||
|
||||
pack:
|
||||
runs-on: windows-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
project: [LibIRD]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
submodules: 'true'
|
||||
|
||||
- name: Setup MSBuild
|
||||
uses: microsoft/setup-msbuild@v2
|
||||
|
||||
- name: Setup NuGet
|
||||
uses: NuGet/setup-nuget@v2
|
||||
with:
|
||||
nuget-version: 'latest'
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v5
|
||||
with:
|
||||
dotnet-version: 10.0.x
|
||||
|
||||
- name: Restore NuGet packages
|
||||
run: nuget restore LibIRD/LibIRD.csproj
|
||||
|
||||
- name: Build
|
||||
run: msbuild ${{ matrix.project }}/${{ matrix.project }}.csproj /p:Configuration=Release
|
||||
|
||||
- name: Pack
|
||||
run: dotnet pack ${{ matrix.project }}/${{ matrix.project }}.csproj -c Release -o ./artifacts
|
||||
|
||||
- name: Upload nupkg
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.project }}
|
||||
path: ./artifacts/*.nupkg
|
||||
|
||||
Vendored
-24
@@ -1,24 +0,0 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"command": "dotnet",
|
||||
"type": "shell",
|
||||
"args": [
|
||||
"build",
|
||||
// Ask dotnet build to generate full paths for file names.
|
||||
"/property:GenerateFullPaths=true",
|
||||
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
|
||||
"/consoleloggerparameters:NoSummary"
|
||||
],
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"reveal": "silent"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetName>irdkit</TargetName>
|
||||
<AssemblyName>irdkit</AssemblyName>
|
||||
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
|
||||
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0;net10.0</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
@@ -14,7 +14,7 @@
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<SelfContained>false</SelfContained>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Version>0.9.5</Version>
|
||||
<Version>1.0.1</Version>
|
||||
|
||||
<!-- Package Properties -->
|
||||
<Authors>Deterous</Authors>
|
||||
@@ -33,8 +33,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.5.0" />
|
||||
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.0" />
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.6.0" />
|
||||
<PackageReference Include="SabreTools.RedumpLib" Version="1.9.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
+94
-2
@@ -113,6 +113,19 @@ namespace IRDKit
|
||||
public bool Verbose { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IRD verify command
|
||||
/// </summary>
|
||||
[Verb("verify", HelpText = "Verify a folder using an IRD")]
|
||||
public class VerifyOptions
|
||||
{
|
||||
[Value(0, Required = true, HelpText = "Path to IRD file to use for validation")]
|
||||
public string IRDPath { get; set; }
|
||||
|
||||
[Value(1, Required = true, HelpText = "Folder path to validate")]
|
||||
public string FolderPath { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Program
|
||||
@@ -127,7 +140,7 @@ namespace IRDKit
|
||||
Console.OutputEncoding = Encoding.UTF8;
|
||||
|
||||
// Parse arguments
|
||||
var result = Parser.Default.ParseArguments<CreateOptions, InfoOptions, DiffOptions, RenameOptions>(args).WithParsed(Run);
|
||||
var result = Parser.Default.ParseArguments<CreateOptions, InfoOptions, DiffOptions, RenameOptions, VerifyOptions>(args).WithParsed(Run);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -452,6 +465,60 @@ namespace IRDKit
|
||||
|
||||
break;
|
||||
|
||||
// Process options from a 'rename' command
|
||||
case VerifyOptions opt:
|
||||
|
||||
string verifyIRDPath = opt.IRDPath;
|
||||
string verifyFolderPath = opt.FolderPath;
|
||||
|
||||
// Validate required parameters
|
||||
if (string.IsNullOrEmpty(verifyIRDPath))
|
||||
{
|
||||
Console.Error.WriteLine("Provide a IRD path to verify with");
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(verifyFolderPath))
|
||||
{
|
||||
Console.Error.WriteLine("Provide a folder path to verify");
|
||||
return;
|
||||
}
|
||||
|
||||
bool switched = false;
|
||||
if (!File.Exists(verifyIRDPath))
|
||||
{
|
||||
// Check if arguments are switched
|
||||
if (File.Exists(verifyFolderPath))
|
||||
{
|
||||
switched = true;
|
||||
string temp = verifyIRDPath;
|
||||
verifyIRDPath = verifyFolderPath;
|
||||
verifyFolderPath = temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Error.WriteLine("Provide a valid IRD file to verify with");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Directory.Exists(verifyFolderPath))
|
||||
{
|
||||
if (switched)
|
||||
{
|
||||
Console.Error.WriteLine("Provide a valid IRD file to verify with");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Error.WriteLine("Provide a valid folder path to verify");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VerifyIRD(verifyIRDPath, verifyFolderPath);
|
||||
|
||||
break;
|
||||
|
||||
// Unknown command
|
||||
default:
|
||||
break;
|
||||
@@ -772,6 +839,32 @@ namespace IRDKit
|
||||
Console.WriteLine(printText.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verify a folder matches against an IRD
|
||||
/// </summary>
|
||||
/// <param name="irdPath">IRD path to verify with</param>
|
||||
/// <param name="folderPath">Folder containing files to verify against</param>
|
||||
public static void VerifyIRD(string irdPath, string folderPath)
|
||||
{
|
||||
// Get file paths and their hashes to verify with
|
||||
var fileHashes = IRD.Read(irdPath).GetFileHashes();
|
||||
|
||||
// Check that all files and their hashes exist in the folder path
|
||||
foreach (var kvp in fileHashes)
|
||||
{
|
||||
string filePath = Path.Combine(folderPath, kvp.Key);
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
Console.WriteLine($"{filePath} doesn't exist");
|
||||
continue;
|
||||
}
|
||||
var hash = HashTool.GetFileHashArray(filePath, HashType.MD5);
|
||||
if (!hash.SequenceEqual(kvp.Value))
|
||||
Console.WriteLine($"{filePath}: {IRD.ByteArrayToHexString(hash)}");
|
||||
}
|
||||
Console.WriteLine("Verification complete!");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an IRD file from an ISO file
|
||||
/// </summary>
|
||||
@@ -945,7 +1038,6 @@ namespace IRDKit
|
||||
string crc32String = LibIRD.IRD.ByteArrayToHexString(crc32).ToLowerInvariant();
|
||||
|
||||
// Convert to UInt for use as UID in IRD
|
||||
Array.Reverse(crc32);
|
||||
uint crc32UInt = BitConverter.ToUInt32(crc32, 0);
|
||||
|
||||
// Search for ISO on redump.org
|
||||
|
||||
@@ -46,3 +46,7 @@ The comparison can be printed to a file, e.g. `-o out.txt` or `--output=`
|
||||
For all options, run `irdkit help rename`
|
||||
|
||||
To rename an IRD (or folder of IRDs) according to a redump DAT, run `irdkit rename -d redump.dat game.ird`
|
||||
|
||||
## Verifying with an IRD
|
||||
|
||||
To verify that a folder containing files from a PS3 disc match the file hashes within an IRD, run `irdkit verify game.ird folder/of/files`
|
||||
|
||||
+79
-3
@@ -1159,8 +1159,9 @@ namespace LibIRD
|
||||
// If making redump-style IRD, save CRC32 hash to UID field
|
||||
if (redump)
|
||||
{
|
||||
isoHasher.Terminate();
|
||||
crc32 = isoHasher.CurrentHashBytes;
|
||||
Array.Reverse(crc32);
|
||||
isoHasher.Dispose();
|
||||
UID = BitConverter.ToUInt32(crc32, 0);
|
||||
}
|
||||
|
||||
@@ -1419,7 +1420,6 @@ namespace LibIRD
|
||||
// Calculate the little-endian 32-bit "IEEE 802.3" CRC value of the IRD contents so far
|
||||
stream.Position = 0;
|
||||
byte[] crc32 = HashTool.GetStreamHashArray(stream, HashType.CRC32, true);
|
||||
Array.Reverse(crc32);
|
||||
|
||||
// Write final CRC value to the stream
|
||||
stream.Write(crc32, 0, 4);
|
||||
@@ -1733,7 +1733,83 @@ namespace LibIRD
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region IRD Validation
|
||||
|
||||
/// <summary>
|
||||
/// Returns dictionary of file paths and their offset
|
||||
/// </summary>
|
||||
/// <param name="cd">CDReader object</param>
|
||||
public Dictionary<string, byte[]> GetFileHashes()
|
||||
{
|
||||
using MemoryStream headerStream = new MemoryStream(Header);
|
||||
using GZipStream gzStream = new GZipStream(headerStream, CompressionMode.Decompress);
|
||||
using MemoryStream isoStream = new MemoryStream();
|
||||
#if NETCOREAPP || NETSTANDARD || NET40_OR_GREATER
|
||||
gzStream.CopyTo(isoStream);
|
||||
#else
|
||||
byte[] buffer = new byte[SectorSize];
|
||||
int bytesRead;
|
||||
while ((bytesRead = gzStream.Read(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
isoStream.Write(buffer, 0, bytesRead);
|
||||
}
|
||||
#endif
|
||||
isoStream.Position = 0;
|
||||
using CDReader reader = new CDReader(isoStream);
|
||||
|
||||
// Get all file paths and their offsets
|
||||
var files = new Dictionary<string, long>();
|
||||
DiscDirectoryInfo rootDir = reader.GetDirectoryInfo("\\");
|
||||
GetFileOffsets(reader, rootDir, files);
|
||||
|
||||
// Get all paths at each offset
|
||||
var offsetToHash = new Dictionary<long, byte[]>();
|
||||
for (int i = 0; i < FileCount; i++)
|
||||
offsetToHash[FileKeys[i]] = FileHashes[i];
|
||||
|
||||
// Return dictionary of paths and hashes
|
||||
var result = new Dictionary<string, byte[]>();
|
||||
foreach (KeyValuePair<string, long> kvp in files)
|
||||
{
|
||||
if (offsetToHash.ContainsKey(kvp.Value))
|
||||
result[kvp.Key] = offsetToHash[kvp.Value];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all file paths from the ISO header
|
||||
/// </summary>
|
||||
/// <param name="reader">CDReader object</param>
|
||||
/// <param name="path">Path to look within</param>
|
||||
/// <param name="files">Dictionary of files and their offset</param>
|
||||
public void GetFileOffsets(CDReader reader, DiscDirectoryInfo path, Dictionary<string, long> files)
|
||||
{
|
||||
foreach (DiscFileInfo fileInfo in path.GetFiles())
|
||||
{
|
||||
string filePath = fileInfo.FullName;
|
||||
Range<long, long>[] fileExtent = reader.PathToClusters(filePath);
|
||||
if (fileExtent == null && fileExtent.Length == 0)
|
||||
throw new IOException($"Unexpected file extents for {filePath}");
|
||||
long offset = fileExtent[0].Offset;
|
||||
for (int i = 1; i < fileExtent.Length; i++)
|
||||
{
|
||||
if (fileExtent[i] == null)
|
||||
throw new IOException($"Unexpected file extents for {filePath}");
|
||||
if (fileExtent[i].Offset < offset)
|
||||
offset = fileExtent[i].Offset;
|
||||
}
|
||||
files[filePath] = offset;
|
||||
}
|
||||
foreach (DiscDirectoryInfo dirInfo in path.GetDirectories())
|
||||
{
|
||||
GetFileOffsets(reader, dirInfo, files);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helper Functions
|
||||
|
||||
|
||||
+3
-11
@@ -2,12 +2,12 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- Assembly Properties -->
|
||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
|
||||
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;net10.0</TargetFrameworks>
|
||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Version>0.9.4</Version>
|
||||
<Version>1.0.1</Version>
|
||||
<PackageOutputPath>../nupkg</PackageOutputPath>
|
||||
|
||||
<!-- Avoid inexact read with 'System.IO.Stream.Read' -->
|
||||
@@ -24,14 +24,6 @@
|
||||
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith(`osx-arm`))">
|
||||
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="!$(RuntimeIdentifier.StartsWith(`osx-arm`))">
|
||||
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="./README.md" Pack="true" PackagePath="" />
|
||||
@@ -44,7 +36,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.4.0" />
|
||||
<PackageReference Include="SabreTools.Hashing" Version="1.6.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -14,6 +14,7 @@ IRDKit is a tool that allows direct use of LibIRD functionality from a command l
|
||||
- Creating an IRD from an ISO: `irdkit create game.iso`
|
||||
- Finding differences between two IRDs: `irdkit diff game1.ird game2.ird`
|
||||
- Renaming an IRD or folder of IRDs using a redump DAT: `irdkit rename -d redump.dat game.ird`
|
||||
- Verify a JB Folder with an IRD: `irdkit verify game.ird folder`
|
||||
|
||||
For detailed usage, read more [here](IRDKit).
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
dotnet publish -c Release -f net9.0 -r win-x86 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj
|
||||
dotnet publish -c Release -f net9.0 -r win-x64 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj
|
||||
dotnet publish -c Release -f net9.0 -r win-arm64 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj
|
||||
dotnet publish -c Release -f net9.0 -r linux-x64 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj
|
||||
dotnet publish -c Release -f net9.0 -r linux-arm64 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj
|
||||
dotnet publish -c Release -f net9.0 -r osx-x64 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj
|
||||
dotnet publish -c Release -f net9.0 -r osx-arm64 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj
|
||||
|
||||
Compress-Archive -Path "./IRDKit/bin/Release/net9.0/win-x86/publish/irdkit.exe" -Destination "./irdkit-win-x86.zip" -CompressionLevel "Optimal"
|
||||
Compress-Archive -Path "./IRDKit/bin/Release/net9.0/win-x64/publish/irdkit.exe" -Destination "./irdkit-win-x64.zip" -CompressionLevel "Optimal"
|
||||
Compress-Archive -Path "./IRDKit/bin/Release/net9.0/win-arm64/publish/irdkit.exe" -Destination "./irdkit-win-arm64.zip" -CompressionLevel "Optimal"
|
||||
Compress-Archive -Path "./IRDKit/bin/Release/net9.0/linux-x64/publish/irdkit" -Destination "./irdkit-linux-x64.zip" -CompressionLevel "Optimal"
|
||||
Compress-Archive -Path "./IRDKit/bin/Release/net9.0/linux-arm64/publish/irdkit" -Destination "./irdkit-linux-arm64.zip" -CompressionLevel "Optimal"
|
||||
Compress-Archive -Path "./IRDKit/bin/Release/net9.0/osx-x64/publish/irdkit" -Destination "./irdkit-osx-x64.zip" -CompressionLevel "Optimal"
|
||||
Compress-Archive -Path "./IRDKit/bin/Release/net9.0/osx-arm64/publish/irdkit" -Destination "./irdkit-osx-arm64.zip" -CompressionLevel "Optimal"
|
||||
Reference in New Issue
Block a user