diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..d6326c5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,36 @@ +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: Restore dependencies + run: dotnet restore + + - 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/* diff --git a/IRDKit/IRDKit.csproj b/IRDKit/IRDKit.csproj index 3ac14b6..fb63d3f 100644 --- a/IRDKit/IRDKit.csproj +++ b/IRDKit/IRDKit.csproj @@ -5,18 +5,21 @@ Exe irdkit irdkit - net6.0;net7.0;net8.0;net9.0 + net6.0;net7.0;net8.0;net9.0 win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64 false latest true + true + true + false true - 0.9.3 + 0.9.5 Deterous Library for ISO Rebuild Data - Copyright (c) Deterous 2023-2024 + Copyright (c) Deterous 2023-2025 README.md https://github.com/Deterous/LibIRD git @@ -30,8 +33,8 @@ - - + + diff --git a/IRDKit/Program.cs b/IRDKit/Program.cs index 89ffed9..b76cd91 100644 --- a/IRDKit/Program.cs +++ b/IRDKit/Program.cs @@ -59,6 +59,9 @@ namespace IRDKit [Option('o', "output", HelpText = "Path to the text or json file to be created (will overwrite)")] 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")] public bool Json { get; set; } @@ -283,7 +286,7 @@ namespace IRDKit string lastIRD = irdFiles.Last(); 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 +328,7 @@ namespace IRDKit } // 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 != "") Console.WriteLine($"Info saved to {opt.OutPath}"); @@ -464,8 +467,9 @@ namespace IRDKit /// /// File to retrieve info from /// Whether to format output as JSON (true) or plain text (false) + /// Whether to print a single JSON object or not /// File to output info to - 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 bool isISO = String.Compare(Path.GetExtension(inPath), ".iso", StringComparison.OrdinalIgnoreCase) == 0; @@ -492,10 +496,10 @@ namespace IRDKit File.AppendAllText(outPath, $"\"{Path.GetFileName(inPath)}\": "); else Console.Write($"\"{Path.GetFileName(inPath)}\": "); - ird.PrintJson(outPath, single); + ird.PrintJson(outPath, single, printAll); } else - IRD.Read(inPath).Print(outPath, Path.GetFileName(inPath)); + IRD.Read(inPath).Print(outPath, Path.GetFileName(inPath), printAll); if (json) return; @@ -518,6 +522,7 @@ namespace IRDKit /// /// Path to ISO file /// Whether to format output as JSON (true) or plain text (false) + /// Whether to print a single JSON object or not /// File to output info to /// /// diff --git a/IRDKit/README.md b/IRDKit/README.md index e536c4c..c3bf5fc 100644 --- a/IRDKit/README.md +++ b/IRDKit/README.md @@ -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` 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` +To print all info in the IRD use `-a` or `--all` ## Comparing IRDs diff --git a/LibIRD/IRD.cs b/LibIRD/IRD.cs index 86713ec..86d83f9 100644 --- a/LibIRD/IRD.cs +++ b/LibIRD/IRD.cs @@ -1561,7 +1561,9 @@ namespace LibIRD /// Prints IRD fields to console /// /// Optional path to save file to - public void Print(string printPath = null, string irdName = null) + /// Optionally print IRD name in output header + /// Optionally print all IRD data + public void Print(string printPath = null, string irdName = null, bool printAll = false) { // Build string from parameters StringBuilder printText = new(); @@ -1579,11 +1581,38 @@ namespace LibIRD printText.AppendLine($"PUP Version: {SystemVersion}"); printText.AppendLine($"Disc Version: {DiscVersion}"); printText.AppendLine($"App Version: {AppVersion}"); + if (printAll) + { + printText.AppendLine($"Header: {ByteArrayToHexString(Header)}"); + printText.AppendLine($"Footer: {ByteArrayToHexString(Footer)}"); + } 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}"); - 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}"); - if (Attachments != 0x0000) + if (printAll || Attachments != 0x0000) printText.AppendLine($"Attachments: {Attachments:X4}"); printText.AppendLine($"Unique ID: {UID:X8}"); printText.AppendLine($"Data 1 Key: {ByteArrayToHexString(Data1Key)}"); @@ -1610,7 +1639,9 @@ namespace LibIRD /// Prints IRD fields to a json object /// /// Optionally print to json file - public void PrintJson(string jsonPath = null, bool single = true) + /// Optionally print single object (no trailing comma) + /// Optionally print all IRD data + public void PrintJson(string jsonPath = null, bool single = true, bool printAll = false) { // Build string from parameters StringBuilder json = new(); @@ -1624,11 +1655,58 @@ namespace LibIRD json.AppendLine($" \"PUP Version\": \"{SystemVersion}\","); json.AppendLine($" \"Disc Version\": \"{DiscVersion}\","); json.AppendLine($" \"App Version\": \"{AppVersion}\","); - json.AppendLine($" \"Regions\": \"{RegionCount}\","); - json.AppendLine($" \"Files\": \"{FileCount}\","); - if (ExtraConfig != 0x0000) + if (printAll) + { + 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}\","); - if (Attachments != 0x0000) + if (printAll || Attachments != 0x0000) json.AppendLine($" \"Attachments\": \"{Attachments:X4}\","); json.AppendLine($" \"Unique ID\": \"{UID:X8}\","); json.AppendLine($" \"Data 1 Key\": \"{ByteArrayToHexString(Data1Key)}\","); diff --git a/LibIRD/LibIRD.csproj b/LibIRD/LibIRD.csproj index 8a2ff15..0eac5fd 100644 --- a/LibIRD/LibIRD.csproj +++ b/LibIRD/LibIRD.csproj @@ -7,7 +7,7 @@ latest true true - 0.9.3 + 0.9.4 ../nupkg @@ -16,7 +16,7 @@ Deterous Library for ISO Rebuild Data - Copyright (c) Deterous 2023-2024 + Copyright (c) Deterous 2023-2025 README.md https://github.com/Deterous/LibIRD/ git