Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1cb4bccd4 | ||
|
|
2379e7ef5a | ||
|
|
ce5b610f92 | ||
|
|
048d70b473 | ||
|
|
0761450a8d |
@@ -0,0 +1,73 @@
|
|||||||
|
name: Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
project: [IRDKit]
|
||||||
|
runtime: [win-x86, win-x64, win-arm64, linux-x64, linux-arm64, osx-x64, osx-arm64]
|
||||||
|
framework: [net8.0]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- name: Setup .NET
|
||||||
|
uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: 9.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
|
||||||
|
|
||||||
|
- name: Upload build
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
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@v4
|
||||||
|
with:
|
||||||
|
submodules: 'true'
|
||||||
|
|
||||||
|
- name: Setup MSBuild
|
||||||
|
uses: microsoft/setup-msbuild@v2
|
||||||
|
|
||||||
|
- name: Setup NuGet
|
||||||
|
uses: NuGet/setup-nuget@v1
|
||||||
|
with:
|
||||||
|
nuget-version: 'latest'
|
||||||
|
|
||||||
|
- name: Setup .NET
|
||||||
|
uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: 9.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
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
// 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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,22 +1,25 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- Assembly Properties -->
|
<!-- Assembly Properties -->
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetName>irdkit</TargetName>
|
<TargetName>irdkit</TargetName>
|
||||||
<AssemblyName>irdkit</AssemblyName>
|
<AssemblyName>irdkit</AssemblyName>
|
||||||
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
|
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
|
||||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
|
||||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||||
|
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
|
||||||
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
|
<SelfContained>false</SelfContained>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
<Version>0.9.2</Version>
|
<Version>0.9.5</Version>
|
||||||
|
|
||||||
<!-- Package Properties -->
|
<!-- Package Properties -->
|
||||||
<Authors>Deterous</Authors>
|
<Authors>Deterous</Authors>
|
||||||
<Description>Library for ISO Rebuild Data</Description>
|
<Description>Library for ISO Rebuild Data</Description>
|
||||||
<Copyright>Copyright (c) Deterous 2023-2024</Copyright>
|
<Copyright>Copyright (c) Deterous 2023-2025</Copyright>
|
||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
<RepositoryUrl>https://github.com/Deterous/LibIRD</RepositoryUrl>
|
<RepositoryUrl>https://github.com/Deterous/LibIRD</RepositoryUrl>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
@@ -30,8 +33,8 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||||
<PackageReference Include="SabreTools.Hashing" Version="1.1.4" />
|
<PackageReference Include="SabreTools.Hashing" Version="1.5.0" />
|
||||||
<PackageReference Include="SabreTools.RedumpLib" Version="1.3.4" />
|
<PackageReference Include="SabreTools.RedumpLib" Version="1.7.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
+107
-22
@@ -59,6 +59,9 @@ namespace IRDKit
|
|||||||
[Option('o', "output", HelpText = "Path to the text or json file to be created (will overwrite)")]
|
[Option('o', "output", HelpText = "Path to the text or json file to be created (will overwrite)")]
|
||||||
public string OutPath { get; set; }
|
public string OutPath { get; set; }
|
||||||
|
|
||||||
|
[Option('a', "all", HelpText = "Print the entire contents of the IRD")]
|
||||||
|
public bool All { get; set; }
|
||||||
|
|
||||||
[Option('j', "json", HelpText = "Print IRD or ISO information as a JSON object")]
|
[Option('j', "json", HelpText = "Print IRD or ISO information as a JSON object")]
|
||||||
public bool Json { get; set; }
|
public bool Json { get; set; }
|
||||||
|
|
||||||
@@ -110,6 +113,19 @@ namespace IRDKit
|
|||||||
public bool Verbose { get; set; }
|
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
|
#endregion
|
||||||
|
|
||||||
#region Program
|
#region Program
|
||||||
@@ -124,7 +140,7 @@ namespace IRDKit
|
|||||||
Console.OutputEncoding = Encoding.UTF8;
|
Console.OutputEncoding = Encoding.UTF8;
|
||||||
|
|
||||||
// Parse arguments
|
// 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>
|
/// <summary>
|
||||||
@@ -283,7 +299,7 @@ namespace IRDKit
|
|||||||
string lastIRD = irdFiles.Last();
|
string lastIRD = irdFiles.Last();
|
||||||
foreach (string file in irdFiles)
|
foreach (string file in irdFiles)
|
||||||
{
|
{
|
||||||
PrintInfo(file, opt.Json, (noISO && file.Equals(lastIRD)), opt.OutPath);
|
PrintInfo(file, opt.Json, (noISO && file.Equals(lastIRD)), opt.OutPath, opt.All);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -325,7 +341,7 @@ namespace IRDKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Print info from given file
|
// Print info from given file
|
||||||
PrintInfo(filePath, opt.Json, true, opt.OutPath);
|
PrintInfo(filePath, opt.Json, true, opt.OutPath, opt.All);
|
||||||
|
|
||||||
if (opt.OutPath != null && opt.OutPath != "")
|
if (opt.OutPath != null && opt.OutPath != "")
|
||||||
Console.WriteLine($"Info saved to {opt.OutPath}");
|
Console.WriteLine($"Info saved to {opt.OutPath}");
|
||||||
@@ -449,6 +465,60 @@ namespace IRDKit
|
|||||||
|
|
||||||
break;
|
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
|
// Unknown command
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -464,8 +534,9 @@ namespace IRDKit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="inPath">File to retrieve info from</param>
|
/// <param name="inPath">File to retrieve info from</param>
|
||||||
/// <param name="json">Whether to format output as JSON (true) or plain text (false)</param>
|
/// <param name="json">Whether to format output as JSON (true) or plain text (false)</param>
|
||||||
|
/// <param name="single">Whether to print a single JSON object or not</param>
|
||||||
/// <param name="outPath">File to output info to</param>
|
/// <param name="outPath">File to output info to</param>
|
||||||
public static void PrintInfo(string inPath, bool json, bool single = true, string outPath = null)
|
public static void PrintInfo(string inPath, bool json, bool single = true, string outPath = null, bool printAll = false)
|
||||||
{
|
{
|
||||||
// Check if file is an ISO
|
// Check if file is an ISO
|
||||||
bool isISO = String.Compare(Path.GetExtension(inPath), ".iso", StringComparison.OrdinalIgnoreCase) == 0;
|
bool isISO = String.Compare(Path.GetExtension(inPath), ".iso", StringComparison.OrdinalIgnoreCase) == 0;
|
||||||
@@ -492,10 +563,10 @@ namespace IRDKit
|
|||||||
File.AppendAllText(outPath, $"\"{Path.GetFileName(inPath)}\": ");
|
File.AppendAllText(outPath, $"\"{Path.GetFileName(inPath)}\": ");
|
||||||
else
|
else
|
||||||
Console.Write($"\"{Path.GetFileName(inPath)}\": ");
|
Console.Write($"\"{Path.GetFileName(inPath)}\": ");
|
||||||
ird.PrintJson(outPath, single);
|
ird.PrintJson(outPath, single, printAll);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
IRD.Read(inPath).Print(outPath, Path.GetFileName(inPath));
|
IRD.Read(inPath).Print(outPath, Path.GetFileName(inPath), printAll);
|
||||||
|
|
||||||
if (json)
|
if (json)
|
||||||
return;
|
return;
|
||||||
@@ -518,6 +589,7 @@ namespace IRDKit
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="isoPath">Path to ISO file</param>
|
/// <param name="isoPath">Path to ISO file</param>
|
||||||
/// <param name="json">Whether to format output as JSON (true) or plain text (false)</param>
|
/// <param name="json">Whether to format output as JSON (true) or plain text (false)</param>
|
||||||
|
/// <param name="single">Whether to print a single JSON object or not</param>
|
||||||
/// <param name="outPath">File to output info to</param>
|
/// <param name="outPath">File to output info to</param>
|
||||||
/// <exception cref="FileNotFoundException"></exception>
|
/// <exception cref="FileNotFoundException"></exception>
|
||||||
/// <exception cref="InvalidFileSystemException"></exception>
|
/// <exception cref="InvalidFileSystemException"></exception>
|
||||||
@@ -767,6 +839,32 @@ namespace IRDKit
|
|||||||
Console.WriteLine(printText.ToString());
|
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>
|
/// <summary>
|
||||||
/// Creates an IRD file from an ISO file
|
/// Creates an IRD file from an ISO file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -944,13 +1042,8 @@ namespace IRDKit
|
|||||||
uint crc32UInt = BitConverter.ToUInt32(crc32, 0);
|
uint crc32UInt = BitConverter.ToUInt32(crc32, 0);
|
||||||
|
|
||||||
// Search for ISO on redump.org
|
// Search for ISO on redump.org
|
||||||
#if !NETFRAMEWORK
|
RedumpClient redump = new();
|
||||||
RedumpHttpClient redump = new();
|
|
||||||
List<int> ids = redump.CheckSingleSitePage("http://redump.org/discs/system/ps3/quicksearch/" + crc32String).ConfigureAwait(false).GetAwaiter().GetResult();
|
List<int> ids = redump.CheckSingleSitePage("http://redump.org/discs/system/ps3/quicksearch/" + crc32String).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
#else
|
|
||||||
RedumpWebClient redump = new();
|
|
||||||
List<int> ids = redump.CheckSingleSitePage("http://redump.org/discs/system/ps3/quicksearch/" + crc32String);
|
|
||||||
#endif
|
|
||||||
int id;
|
int id;
|
||||||
if (ids.Count == 0)
|
if (ids.Count == 0)
|
||||||
{
|
{
|
||||||
@@ -963,11 +1056,7 @@ namespace IRDKit
|
|||||||
string sha1String = HashTool.GetFileHash(isoPath, HashType.SHA1);
|
string sha1String = HashTool.GetFileHash(isoPath, HashType.SHA1);
|
||||||
|
|
||||||
// Search redump.org for SHA1 hash
|
// Search redump.org for SHA1 hash
|
||||||
#if !NETFRAMEWORK
|
|
||||||
List<int> ids2 = redump.CheckSingleSitePage("http://redump.org/discs/system/ps3/quicksearch/" + sha1String).ConfigureAwait(false).GetAwaiter().GetResult();
|
List<int> ids2 = redump.CheckSingleSitePage("http://redump.org/discs/system/ps3/quicksearch/" + sha1String).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
#else
|
|
||||||
List<int> ids2 = redump.CheckSingleSitePage("http://redump.org/discs/system/ps3/quicksearch/" + sha1String);
|
|
||||||
#endif
|
|
||||||
if (ids2.Count == 0)
|
if (ids2.Count == 0)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("ISO not found in redump and no valid key provided, cannot create IRD");
|
Console.Error.WriteLine("ISO not found in redump and no valid key provided, cannot create IRD");
|
||||||
@@ -987,12 +1076,8 @@ namespace IRDKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Download key file from redump.org
|
// Download key file from redump.org
|
||||||
#if !NETFRAMEWORK
|
byte[] key = redump.DownloadData($"http://redump.org/disc/{id}/key").ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
byte[] key = redump.GetByteArrayAsync($"http://redump.org/disc/{id}/key").ConfigureAwait(false).GetAwaiter().GetResult();
|
if (key == null || key.Length != 16)
|
||||||
#else
|
|
||||||
byte[] key = redump.DownloadData($"http://redump.org/disc/{id}/key");
|
|
||||||
#endif
|
|
||||||
if (key.Length != 16)
|
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("Invalid key obtained from redump and no valid key provided, cannot create IRD");
|
Console.Error.WriteLine("Invalid key obtained from redump and no valid key provided, cannot create IRD");
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ For all options, run `irdkit help info`
|
|||||||
To print info about an ISO or IRD file, run `irdkit info game.iso` or `irdkit info game.ird`
|
To print info about an ISO or IRD file, run `irdkit info game.iso` or `irdkit info game.ird`
|
||||||
The info can be printed to a file, e.g. `-o out.txt` or `--output=`
|
The info can be printed to a file, e.g. `-o out.txt` or `--output=`
|
||||||
The info can be formatted as a JSON with `-j` or `--json`
|
The info can be formatted as a JSON with `-j` or `--json`
|
||||||
|
To print all info in the IRD use `-a` or `--all`
|
||||||
|
|
||||||
## Comparing IRDs
|
## Comparing IRDs
|
||||||
|
|
||||||
|
|||||||
+163
-9
@@ -1561,7 +1561,9 @@ namespace LibIRD
|
|||||||
/// Prints IRD fields to console
|
/// Prints IRD fields to console
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="printPath">Optional path to save file to</param>
|
/// <param name="printPath">Optional path to save file to</param>
|
||||||
public void Print(string printPath = null, string irdName = null)
|
/// <param name="printAll">Optionally print IRD name in output header</param>
|
||||||
|
/// <param name="printAll">Optionally print all IRD data</param>
|
||||||
|
public void Print(string printPath = null, string irdName = null, bool printAll = false)
|
||||||
{
|
{
|
||||||
// Build string from parameters
|
// Build string from parameters
|
||||||
StringBuilder printText = new();
|
StringBuilder printText = new();
|
||||||
@@ -1579,11 +1581,38 @@ namespace LibIRD
|
|||||||
printText.AppendLine($"PUP Version: {SystemVersion}");
|
printText.AppendLine($"PUP Version: {SystemVersion}");
|
||||||
printText.AppendLine($"Disc Version: {DiscVersion}");
|
printText.AppendLine($"Disc Version: {DiscVersion}");
|
||||||
printText.AppendLine($"App Version: {AppVersion}");
|
printText.AppendLine($"App Version: {AppVersion}");
|
||||||
|
if (printAll)
|
||||||
|
{
|
||||||
|
printText.AppendLine($"Header: {ByteArrayToHexString(Header)}");
|
||||||
|
printText.AppendLine($"Footer: {ByteArrayToHexString(Footer)}");
|
||||||
|
}
|
||||||
printText.AppendLine($"Regions: {RegionCount}");
|
printText.AppendLine($"Regions: {RegionCount}");
|
||||||
|
if (printAll)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < RegionCount; i++)
|
||||||
|
{
|
||||||
|
printText.Append($" Region {i} : ");
|
||||||
|
if (RegionHashes[i] == null)
|
||||||
|
printText.AppendLine($"{ByteArrayToHexString(NullMD5)}");
|
||||||
|
else
|
||||||
|
printText.AppendLine($"{ByteArrayToHexString(RegionHashes[i])}");
|
||||||
|
}
|
||||||
|
}
|
||||||
printText.AppendLine($"Files: {FileCount}");
|
printText.AppendLine($"Files: {FileCount}");
|
||||||
if (ExtraConfig != 0x0000)
|
if (printAll)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < FileCount; i++)
|
||||||
|
{
|
||||||
|
printText.Append($" {FileKeys[i]:X7} : ");
|
||||||
|
if (FileHashes[i] == null)
|
||||||
|
printText.AppendLine($"{ByteArrayToHexString(NullMD5)}");
|
||||||
|
else
|
||||||
|
printText.AppendLine($"{ByteArrayToHexString(FileHashes[i])}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (printAll || ExtraConfig != 0x0000)
|
||||||
printText.AppendLine($"Extra Config: {ExtraConfig:X4}");
|
printText.AppendLine($"Extra Config: {ExtraConfig:X4}");
|
||||||
if (Attachments != 0x0000)
|
if (printAll || Attachments != 0x0000)
|
||||||
printText.AppendLine($"Attachments: {Attachments:X4}");
|
printText.AppendLine($"Attachments: {Attachments:X4}");
|
||||||
printText.AppendLine($"Unique ID: {UID:X8}");
|
printText.AppendLine($"Unique ID: {UID:X8}");
|
||||||
printText.AppendLine($"Data 1 Key: {ByteArrayToHexString(Data1Key)}");
|
printText.AppendLine($"Data 1 Key: {ByteArrayToHexString(Data1Key)}");
|
||||||
@@ -1610,7 +1639,9 @@ namespace LibIRD
|
|||||||
/// Prints IRD fields to a json object
|
/// Prints IRD fields to a json object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="jsonPath">Optionally print to json file</param>
|
/// <param name="jsonPath">Optionally print to json file</param>
|
||||||
public void PrintJson(string jsonPath = null, bool single = true)
|
/// <param name="single">Optionally print single object (no trailing comma)</param>
|
||||||
|
/// <param name="printAll">Optionally print all IRD data</param>
|
||||||
|
public void PrintJson(string jsonPath = null, bool single = true, bool printAll = false)
|
||||||
{
|
{
|
||||||
// Build string from parameters
|
// Build string from parameters
|
||||||
StringBuilder json = new();
|
StringBuilder json = new();
|
||||||
@@ -1624,11 +1655,58 @@ namespace LibIRD
|
|||||||
json.AppendLine($" \"PUP Version\": \"{SystemVersion}\",");
|
json.AppendLine($" \"PUP Version\": \"{SystemVersion}\",");
|
||||||
json.AppendLine($" \"Disc Version\": \"{DiscVersion}\",");
|
json.AppendLine($" \"Disc Version\": \"{DiscVersion}\",");
|
||||||
json.AppendLine($" \"App Version\": \"{AppVersion}\",");
|
json.AppendLine($" \"App Version\": \"{AppVersion}\",");
|
||||||
json.AppendLine($" \"Regions\": \"{RegionCount}\",");
|
if (printAll)
|
||||||
json.AppendLine($" \"Files\": \"{FileCount}\",");
|
{
|
||||||
if (ExtraConfig != 0x0000)
|
json.AppendLine($" \"Header\": \"{ByteArrayToHexString(Header)}\",");
|
||||||
|
json.AppendLine($" \"Footer\": \"{ByteArrayToHexString(Footer)}\",");
|
||||||
|
}
|
||||||
|
if (!printAll)
|
||||||
|
json.AppendLine($" \"Regions\": \"{RegionCount}\",");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
json.Append($" \"Regions\": [ ");
|
||||||
|
for (int i = 0; i < RegionCount - 1; i++)
|
||||||
|
{
|
||||||
|
if (RegionHashes[i] == null)
|
||||||
|
json.Append($"\"{ByteArrayToHexString(NullMD5)}\", ");
|
||||||
|
else
|
||||||
|
json.Append($"\"{ByteArrayToHexString(RegionHashes[i])}\", ");
|
||||||
|
}
|
||||||
|
if (RegionCount > 0)
|
||||||
|
{
|
||||||
|
if (RegionHashes[RegionCount - 1] == null)
|
||||||
|
json.Append($"\"{ByteArrayToHexString(NullMD5)}\"");
|
||||||
|
else
|
||||||
|
json.Append($"\"{ByteArrayToHexString(RegionHashes[RegionCount - 1])}\"");
|
||||||
|
}
|
||||||
|
json.AppendLine(" ],");
|
||||||
|
}
|
||||||
|
if(!printAll)
|
||||||
|
json.AppendLine($" \"Files\": \"{FileCount}\",");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
json.Append($" \"Files\": [ ");
|
||||||
|
for (int i = 0; i < RegionCount - 1; i++)
|
||||||
|
{
|
||||||
|
json.Append($" \"{FileKeys[i]}\" : ");
|
||||||
|
if (RegionHashes[i] == null)
|
||||||
|
json.Append($"\"{ByteArrayToHexString(NullMD5)}\", ");
|
||||||
|
else
|
||||||
|
json.Append($"\"{ByteArrayToHexString(FileHashes[i])}\", ");
|
||||||
|
}
|
||||||
|
if (FileCount > 0)
|
||||||
|
{
|
||||||
|
json.Append($" \"{FileKeys[FileCount - 1]}\" : ");
|
||||||
|
if (FileHashes[FileCount - 1] == null)
|
||||||
|
json.Append($"\"{ByteArrayToHexString(NullMD5)}\"");
|
||||||
|
else
|
||||||
|
json.Append($"\"{ByteArrayToHexString(FileHashes[FileCount - 1])}\"");
|
||||||
|
}
|
||||||
|
json.AppendLine(" ],");
|
||||||
|
}
|
||||||
|
if (printAll || ExtraConfig != 0x0000)
|
||||||
json.AppendLine($" \"Extra Config\": \"{ExtraConfig:X4}\",");
|
json.AppendLine($" \"Extra Config\": \"{ExtraConfig:X4}\",");
|
||||||
if (Attachments != 0x0000)
|
if (printAll || Attachments != 0x0000)
|
||||||
json.AppendLine($" \"Attachments\": \"{Attachments:X4}\",");
|
json.AppendLine($" \"Attachments\": \"{Attachments:X4}\",");
|
||||||
json.AppendLine($" \"Unique ID\": \"{UID:X8}\",");
|
json.AppendLine($" \"Unique ID\": \"{UID:X8}\",");
|
||||||
json.AppendLine($" \"Data 1 Key\": \"{ByteArrayToHexString(Data1Key)}\",");
|
json.AppendLine($" \"Data 1 Key\": \"{ByteArrayToHexString(Data1Key)}\",");
|
||||||
@@ -1655,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
|
#region Helper Functions
|
||||||
|
|
||||||
|
|||||||
+13
-13
@@ -1,19 +1,22 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- Assembly Properties -->
|
<!-- 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</TargetFrameworks>
|
||||||
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
<Version>0.9.1</Version>
|
<Version>0.9.5</Version>
|
||||||
<PackageOutputPath>../nupkg</PackageOutputPath>
|
<PackageOutputPath>../nupkg</PackageOutputPath>
|
||||||
|
|
||||||
|
<!-- Avoid inexact read with 'System.IO.Stream.Read' -->
|
||||||
|
<NoWarn>CA2022</NoWarn>
|
||||||
|
|
||||||
<!-- Package Properties -->
|
<!-- Package Properties -->
|
||||||
<Authors>Deterous</Authors>
|
<Authors>Deterous</Authors>
|
||||||
<Description>Library for ISO Rebuild Data</Description>
|
<Description>Library for ISO Rebuild Data</Description>
|
||||||
<Copyright>Copyright (c) Deterous 2023-2024</Copyright>
|
<Copyright>Copyright (c) Deterous 2023-2025</Copyright>
|
||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
<RepositoryUrl>https://github.com/Deterous/LibIRD/</RepositoryUrl>
|
<RepositoryUrl>https://github.com/Deterous/LibIRD/</RepositoryUrl>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
@@ -22,21 +25,18 @@
|
|||||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith(`osx-arm`))">
|
|
||||||
<TargetFrameworks>net6.0;net7.0;net8.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</TargetFrameworks>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="./README.md" Pack="true" PackagePath="" />
|
<None Include="./README.md" Pack="true" PackagePath="" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Support for old .NET versions -->
|
||||||
|
<ItemGroup Condition="$(TargetFramework.StartsWith(`net2`))">
|
||||||
|
<PackageReference Include="Net30.LinqBridge" Version="1.3.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="SabreTools.Hashing" Version="1.1.4" />
|
<PackageReference Include="SabreTools.Hashing" Version="1.5.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</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`
|
- Creating an IRD from an ISO: `irdkit create game.iso`
|
||||||
- Finding differences between two IRDs: `irdkit diff game1.ird game2.ird`
|
- 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`
|
- 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).
|
For detailed usage, read more [here](IRDKit).
|
||||||
|
|
||||||
|
|||||||
+14
-14
@@ -1,15 +1,15 @@
|
|||||||
dotnet publish -c Release -f net8.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-x86 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj
|
||||||
dotnet publish -c Release -f net8.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-x64 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj
|
||||||
dotnet publish -c Release -f net8.0 -r win-arm64 --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 net8.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-x64 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj
|
||||||
dotnet publish -c Release -f net8.0 -r linux-arm64 --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 net8.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-x64 --self-contained=false -p:PublishSingleFile=true -p:DebugType=None IRDKit\IRDKit.csproj
|
||||||
dotnet publish -c Release -f net8.0 -r osx-arm64 --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/net8.0/win-x86/publish/irdkit.exe" -Destination "./irdkit-win-x86.zip" -CompressionLevel "Optimal"
|
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/net8.0/win-x64/publish/irdkit.exe" -Destination "./irdkit-win-x64.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/net8.0/win-arm64/publish/irdkit.exe" -Destination "./irdkit-win-arm64.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/net8.0/linux-x64/publish/irdkit" -Destination "./irdkit-linux-x64.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/net8.0/linux-arm64/publish/irdkit" -Destination "./irdkit-linux-arm64.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/net8.0/osx-x64/publish/irdkit" -Destination "./irdkit-osx-x64.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/net8.0/osx-arm64/publish/irdkit" -Destination "./irdkit-osx-arm64.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